All about forward_list STL in c++ for competitive programming( initialization, traversal and methods/functions ) :
forward_list STL Important Points: It is a sequence container that allows constant time insert and erase operations anywhere within the container. It is same as the singly linked list in c but with a huge advantage of availability of direct functions/methods for many operations. Its objects can only be iterated in one direction i.e forward because of single link. Remember to use the header file #include<forward_list> before using forward_list STL. forward_list vs other sequence containers: forward_list perform generally better in inserting, extracting and moving elements to any position within the container. forward_list lacks direct access to elements by their position. For example - to access the 6th element in it one has to iterate from beginning to that position. list vs forward_list: forward_list is very similar to list and the main difference being is, in list elements can be iterated in from both directions i.e forward and backward. forward_list is less bulky th