Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement List

Shulou Source: shulou.com Published: 2022-06-03 02:38:08 09月17日 Update

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

Tags: Location content article iteration two-way container sequence similarity not much advantage range inner most constant bottom copy quantity method more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn MySQL MariaDB OPPO Reno