added functions to be used in lists (#18541)
This commit is contained in:
committed by
Quincy Larson
parent
8b1c33e704
commit
bcd9eaf92f
@ -12,8 +12,22 @@ whose job is to maintain the order of the list elements kind of like the link be
|
||||
of how Lists are organized compared to Vectors and Arrays.
|
||||

|
||||
|
||||
Traversal in a list is slow as compared to Vectors and Arrays, but once a position has been found, insertion and deletion are quick.
|
||||
|
||||
## How to declare a List
|
||||
If you want to declare a List of Numbers you write:
|
||||
|
||||
'''std::list<int> Numbers;'''
|
||||
|
||||
## Functions used with List
|
||||
size() : Returns the number of elements in the list
|
||||
begin() : Returns an iterator pointing to the first element of the list
|
||||
end() : Returns an iterator pointing to the theoretical last element which follows the last element
|
||||
push_front(data) – Adds a new element with value 'data' at the beginning of the list
|
||||
push_back(data) – Adds a new element with value 'data' at the end of the list
|
||||
pop_front() – Removes the first element of the list
|
||||
pop_back() – Removes the last element of the list
|
||||
|
||||
## How to use these Functions
|
||||
|
||||
Numbers.size();
|
||||
|
Reference in New Issue
Block a user