ode/inc/set.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 #ifndef SET_H_
       
     2 #define SET_H_
       
     3 
       
     4 typedef class pair pair;
       
     5 typedef class iterator iterator;
       
     6 
       
     7 #define MAX 50
       
     8 
       
     9 
       
    10 
       
    11 class set
       
    12 {
       
    13    private:
       
    14 		int n; 
       
    15 		pair* el;
       
    16    public:
       
    17 		set(); //constructor
       
    18 		int addElem(pair e);  //adds the specified pair to this set
       
    19 		int delElem(pair e); //removes the specified pair from this set
       
    20 		int belongs(pair e); // returns true if this set contains the e pair.
       
    21 		int length(); //returns the number of pairs in this set
       
    22     	int isEmpty(); //returns true if this set contains no pairs.
       
    23 		pair getElem(int i); //returns the i-th pair 
       
    24 		iterator* setIterator(); //returns an iterator over the pairs in this set.
       
    25 		~set(); //destructor
       
    26 };
       
    27 
       
    28 class iterator
       
    29 {
       
    30 	private:         
       
    31 		set* s;
       
    32   		int current; //current refers the current pair
       
    33 	public:
       
    34     	iterator(set* sc); //constructor
       
    35    		~iterator(); //destructor
       
    36     	pair getElem(); //returns  the current pair 
       
    37     	int hasNext(); //returns true if the iteration has more pairs.
       
    38 		void next(); // moves the current to the next pair
       
    39     	void setToFirst(); // first pair is current
       
    40 };
       
    41 
       
    42 class pair
       
    43 {
       
    44 	private:
       
    45 		int anum1;
       
    46 		int anum2;
       
    47 	public:
       
    48 		pair();
       
    49 		pair(int num1, int num2);
       
    50 		~pair();
       
    51 		int getNum1();
       
    52 		int getNum2();
       
    53 };
       
    54 
       
    55 
       
    56 #endif /*SET_H_*/