Title: Link Lists
1Link Lists
2Comparison of STL Containers
3List Operations
Constructors listltTgt L construct L as an
empty list listltTgt L(n) construct L as a list
to contain n elements listltTgt L(n,initv)
construct L as a list of n elements each set to
initv listltTgt L(fptr,lptr) construct L as a list
to contain copies of elements
in locations fptr thru
lprt
4List operations
L.empty( ) return true if list contains no
elements L.size( ) return number of values
contained in the list L.push_back(v) append v at
the end of the list, list becomes one
longer L.push_front(v) insert v in front of the
lists first element, list becomes one
longer L.insert(pos,v) insert v at iterator
position pos, return an iterator pointing to
it L.insert(pos,n,v) insert n copies of v at
iterator position pos L.insert(pos,fprt,lptr) inse
rt copies of all elements in range fptr to lptr
at iterator
position pos L.pop_back( ) erase lists last
element L.pop_front( ) erase lists first
element L.erase(pos) erase the value at iterator
position pos L.erase(pos1, pos2) erase all values
from iterator position pos1 ti iterator position
pos2 L.remove(v) erase all elements in list that
match value v
5List operations
L.unique( ) replace all occurrences of a
repeating sequence with a single
occurrence of the
sequence L.front( ) return a reference to the
lists first element L.back( ) return a
reference to the lists last element L.begin(
) return an iterator positioned at lists first
element L.end( ) return an iterator positioned
at lists last element L.rbegin( ) return a
reverse iterator positioned at lists last
element L.rend( ) return a reverse iterator
positioned one element before lists first
element L.sort( ) sort
lists elements (using lt) L1.merge(L2) merge ans
sort elements of L2 into L1 l2 ends up
empty L1.splice(pos, L2) move all elements in L_at_
to iterator position pos of L1 L1.splice(to, L2,
from) move element in L2 at iterator position
from into L1
iterator position pos
6List operations
L1.swap(L2) swap the contents of the two
lists L1L2 pure assignment L1 L2 return true
if and only if L1 contains the same items as L2
and in the same
order L1 lt L2 return true if and only if L1
is lexicographically less than L2