1. For all operations of a table, arrays can be used, and arrays are statically allocated, but the vector class of the internal storage array allows to increase the size of the array by one times when needed.
2. It is precisely because of the implementation of the array that printlist is executed in linear time, and findkth even through constant time. The worst is the insertion and deletion, if the position is not good, for example, in position No. 0 to insert the entire array will need to move all the elements back to O (N). To avoid the linear overhead of insertions and deletions, we started using a technique called a list of lists (Linked).
3. The list consists of a number of nodes that are connected in memory, and each node has a link to the table element and the node of the element's successor. This is called next chain, and naturally the next chain of the last unit points to null.
4.STL is the full name of "Standard Template Library", the Chinese name is to do the "Standards Templates gallery." The table ADT is in it.
5. An array is a pointer to memory variable, memory block can be allocated by new[], but also must be released with delete[], the size of the memory block cannot be changed.
6. Combine a new node containing x with the nodes pointed to by P and P.prev, and the pointer assignment can be written as follows.
*newNode=new Node(x,p->prev,p);p->prev->next=newNode;p->prev=neweNode;
But it can also be merged:
*newNode=new Node(x,p->prev,p);p->prev=p->prev->next=newNode;
It can then be further merged:
p->prev=p->prev->next=new Node(x,p->prev,p);
So you can write insert operations like this:
& x){ *p=itr.current; theSize++; return iterator(p->prev=p->prev->next=new Node(x,p->prev,p));}
7. Similarly, for a two-way list of delete operations, this would be the case:
p->prev->next=p->next;p->next->prev=p->prev;delete p;
The Insert function after the modification.
iterator insert(iterator itr,constObject & x){ itr.assertIsValid(); if(itr.theList!=this) throw IteratorMismatchException(); Node *p=itr.current; theSize++; returnthis,p->prev=p-prev->next=new Node(x,p->prev,p));}
Review Table ADT 7 points