How to implement List
Editor to share with you how to achieve List, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
Summary of implementation methods of STL_list
List is a sequential container that inserts and deletes anywhere within a constant range, and can be iterated in two directions; the bottom layer is a bi-directional linked list structure; like forword_list, forword_list is a single linked list; compared with other sequential containers (array,vector,deque), list has the advantage that it can be inserted anywhere, but its disadvantage is that it cannot be accessed anywhere.
1) list mylist
2) list mylist (10) / / here you can directly specify the number of table items (10), or you can specify something such as (10), which indicates that the range is 1.
3) list mylist1 (mylist) / / this is the copy call
4) list mylist = {1, 2, 3, 4}
5) list mylist1 (mylist.begin (), mylist.end ()); / / this is the iterator method
[] Operation cannot be used to access list. To access list, iterator method can be used: list::iterator it = mylist.begin (); while (it! = mylist.end ()) {cout