forward_lists:
Similar to lists, allow constant time insertion and erasing operations. forward_lists are implemented using singly-linked lists. They are different from list in that each node stores the link only to the next node and not the previous node as is the case with lists. forward_lists are mode efficient than lists, at least in most cases, although they can only be iterated forward.
Performs awesomely in inserting, extracting and moving elements in any position within the container.
As was the case with lists, the forward_lists lack direct access to any element, thus we have to iterate to access any element from the start, for example, if we want to access the 8th element, we'll have to iterate all the way to it. Further, these consume extra memory because they have to store the links to the next node.
It is designed with keeping efficiency in mind, even it does not contain the size function to make because it will decrease a bit of its efficiency, as it will have to store the counter.
Member functions:
- before_begin: returns an iterator to the point before the beginning of forward_list.
- begin: returns an iterator to the start of the forward_list.
- end: returns an iterator to the end of the forward_list.
- empty: check if the forward_list is empty.
- front: access first element
- assign: assign the content of one linked list to the other.
- emplace_front: create and insert an element at the start of the forward_list
- push_frot: insert an element to the start of the forward_list
- pop_front: delete the first element
- emplace_after: emplace after a fixed node
- insert_after: insert after a fixed node
- erase_after: erase the node after a fixed node
- swap: swap contents of two forward_list.
- clear: clear the content
- remove: remove elements with a specific value
- remove_if: remove elements satisfying a condition
- unique: delete duplicates
- merge: merge two forward_lists.
- sort: sort the forward_list
- reverse: reverse the contents of forward_list
Here is the link to the official documentation of forward_list: http://www.cplusplus.com/reference/forward_list/forward_list/
No comments:
Post a Comment