Hi All,
I am trying to implement various kinds of finite automaton simulators; I
have abstract the transition mappings to be from a "Set" to another "Set"
taking on some "Input". I come up with the data structure like the following
to represent automatons,
map<Set, map<Input, Set> >
However, for deterministic finite automaton, I derive the class "State" from
the class "Set", and the class "Symbol" from the class "Input". Now, I want
to write a function that takes a string and run the automaton against the
string. Therefore, for deterministic finite automaton, the signature of the
function would be,
run(string s, map<State, map<Symbol, State> >);
I am wondering if there is any way for me to write something like the
following,
run(string s, map<Set, map<Input, Set> >);
so that I can pass different kinds of automaton representation to the
function.
If I am not on the right track in the design, could someone point me out how
I should structure the whole thing to make the code look beautiful?
-Daniel. 1 1683
On Fri, 9 Jul 2004 18:24:42 +0800, Daniel Suen <tt*****@yahoo.com> wrote: Hi All,
I am trying to implement various kinds of finite automaton simulators; I have abstract the transition mappings to be from a "Set" to another "Set" taking on some "Input". I come up with the data structure like the following to represent automatons,
map<Set, map<Input, Set> >
However, for deterministic finite automaton, I derive the class "State" from the class "Set", and the class "Symbol" from the class "Input". Now, I want to write a function that takes a string and run the automaton against the string. Therefore, for deterministic finite automaton, the signature of the function would be,
run(string s, map<State, map<Symbol, State> >);
I am wondering if there is any way for me to write something like the following,
run(string s, map<Set, map<Input, Set> >);
so that I can pass different kinds of automaton representation to the function.
If I am not on the right track in the design, could someone point me out how I should structure the whole thing to make the code look beautiful?
-Daniel.
Use a pointer (or preferably a smart pointer) for the key and a comparison
object to call a virtual method on the keys.
Whether that's good design for your application I couldn't say but it will
get you a map with a polymorphic key.
john This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave |
last post by:
What is the expected output of this program and why???
#include <iostream>
using namespace std;
class base
{
|
by: Maurice Termeer |
last post by:
Hi, suppose i've got this:
class a {
public:
int n;
};
class b : public a {
public:
};
|
by: verec |
last post by:
One problem I've come accross in designing a specific version of auto_ptr
is that I have to disntiguish between "polymorphic" arguments and "plain" ones,
because the template has to, internally,...
|
by: verec |
last post by:
Last week I asked here how I could detect that a T was polymorphic, and
received
very thoughtful and useful replies that I used straight away. Thanks to all who
answered.
This week, it turns...
|
by: Mr. Ed |
last post by:
I have a base class which has about 150 derived classes. Most of the
derived classes are very similar, and many don't change the base class
at all. All the derived classes have a unique factory...
|
by: James Fortune |
last post by:
In response to different users or situations (data context) I
transform the appearance and characteristics of Access Forms through
code. This seems to fit in with the idea of polymorphism. Do...
|
by: Bob |
last post by:
Hi,
'Shadowed' properties are not polymorphic. (See thread 'Inheritance and late
binding')
They should be.
Problem:
Base class has read only property 'X'.
Derived class must have read / write...
|
by: Osamede.Zhang |
last post by:
Compiler store a pointer table in each object with virtual fuction to
implement polymorphic,isn't it? But where is the pointer table?
It seems that object only store a pointer to the table,the...
|
by: Arindam |
last post by:
#include <cstdio>
struct Test {
void bar() {
foo();
}
private:
virtual void foo() {
printf("Test\n");
}
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |