Chapter 1 Set
A set is also called a set structure. It is composed of different data elements of the same type. There is no logical relationship between elements.
To facilitate insertion and deletion of nodes in a single-chain table that represents a set, a valueless node is usually added to the header, which is called an additional header node.
Sequential storage structure and operation implementation of a Set
Public class sequenceset implements set {final int maxsize = 10; // initial length of the array private object [] setarray; // array declaration, the element type is the system-provided base class private int length; // The current length of the Set // The Operation Public sequenceset () {} public sequenceset (int n) {} public Boolean add (Object OBJ) {} public Boolean remove (Object OBJ) {} public Boolean contains (Object OBJ) {} public object value (int I) {} public object find (Object OBJ) {} public int size () {} public Boolean isempty () {} public void output () {} public set union (Set set) {} public set intersection (Set set) {} public void clear (){}}
Link storage structure and operation implementation of a Set
Public class node {object element; node next; Public node (node nextval) {next = nextval;} public node (Object OBJ, node nextval) {element = OBJ; next = nextval ;}} public class linkset implements set {private node head; // header pointer private int length; // chain table length}
A set is a data structure. When performing operations on any data structure, you must first define the abstract data type and then define the corresponding abstract interface class, an Implementation class that uses a storage structure.