主题:[讨论]帮我看看我的数据结构
大家帮我看一下,我建的这个数据结构对不对(用java):
class StateStack implements Stack{
static private int StateNumber;//the number of the elements in the stack
static private int top; //the top of the statestack
static private State stateobj;//the element in the stack is the object of the class state
static private ArrayList statearray;
//define the class state
class State
{
static private int stateName;//we use integer variables to indicate the state
static private boolean isEndState;
static private boolean isSelfEnclosure;
static private ArrayList transtoken;//we use a variable array to indicate the collection of transtoken
}
//constructor,it equals the initialization
public State()
{
int stateName=-1;
boolean isEndState=false;
boolean isEnclosure=false;
ArrayList transtoken=new ArrayList();
}
public StateStack()
{
int top==-1;
int StateNumber=statearray.size();
State s=new State();
}
//define the methods
public void push(int s)
{
stateobje=new Stack();
s=stateobj.stateName;
++top;
statearray.add(s);
}
public boolean isEmpmty()
{
return (top==-1)
}
public int pop()
{
if(isEmpty())
throw new EmptyStackException();
return statearray.remove(statckarray.size()-1);
}
public void int peek
{
if(isEmpty())
throw new EmptyStackException();
return statearray.get(statearray.size()-1);
}
}
class StateStack implements Stack{
static private int StateNumber;//the number of the elements in the stack
static private int top; //the top of the statestack
static private State stateobj;//the element in the stack is the object of the class state
static private ArrayList statearray;
//define the class state
class State
{
static private int stateName;//we use integer variables to indicate the state
static private boolean isEndState;
static private boolean isSelfEnclosure;
static private ArrayList transtoken;//we use a variable array to indicate the collection of transtoken
}
//constructor,it equals the initialization
public State()
{
int stateName=-1;
boolean isEndState=false;
boolean isEnclosure=false;
ArrayList transtoken=new ArrayList();
}
public StateStack()
{
int top==-1;
int StateNumber=statearray.size();
State s=new State();
}
//define the methods
public void push(int s)
{
stateobje=new Stack();
s=stateobj.stateName;
++top;
statearray.add(s);
}
public boolean isEmpmty()
{
return (top==-1)
}
public int pop()
{
if(isEmpty())
throw new EmptyStackException();
return statearray.remove(statckarray.size()-1);
}
public void int peek
{
if(isEmpty())
throw new EmptyStackException();
return statearray.get(statearray.size()-1);
}
}