Sequential linear table storage structure, it is easy to implement the random access linear table I elements of operation, but to implement the delete or insert operations need to move a large number of data elements. Therefore, the sequential table is adapted to the stable linear table, such as the staff salary table and the Student status table.
1 #defineList_init_size 10//initial allocation of the linear table storage space2 #defineList_increment 2//linear table storage space allocation increment3 4typedefintElemtype;//defining abstract data types Elemtype as shaping variables5 6 structSqList7 {8Elemtype *elem;//Storage space Base9 intLength//Linear table Current lengthTen intListsize;//Current allocated storage capacity One};
Understanding of this struct: first, the variable type of elemtype is defined externally with a TypeDef, which increases the flexibility of the code. If you want to modify the type of the storage variable later, you just need to modify the Elemtype type.
Second, the Elemtype pointer variable is used here, which is equivalent to the Elemtype elem[list_init_size when using the array, but the pointer is more flexible, as can be seen in the basic operation function of the sequential table.
Sequential representation of linear tables in data structures dynamically allocated storage structures