Header:
|
plang/factor/list_.hpp
|
Class:
|
vector_ : factor
|
list
is built-in data type represents linked list. In C++ code boost::shared_ptr<list_>
is class corresponding to list.
list_ has
std::list<factor::shared_ptr> data
type member named l which contains values of that
object.
Members
Methods
list()
default constructor, set l to empty list
effects
l=list_type()
list(list& x)
copy constructor, deepcopy x.l
parameters
list& x
object to be copied
effects
deepcopy(x)
list(unsigned int size)
constructor, create list contains size of nil elements
parameters
unsigned int size
size of list
effects
resize(size,nil())
template<class T> list(unsigned int size, T& value)
constructor, create list contains size of copyof(value)
parameters
unsigned int size
size of list
T& value
value of elements
effects
resize(size,value)
list& operator =(list& x)
deepcopy x.l
parameters
list& x
object to be copied
effects
deepcopy(x)
returns
this
bool empty()
test if list is empty
returns
l.empty()
unsigned int size()
get size of l
returns
l.size()
template<class T> T& front()
get first element in l
returns
l[0]
exceptions
range_error
if l is empty
template<class T> T& back()
get last element in l
returns
l[size()-1]
exceptions
range_error
if l is empty
template<class T> T& pop_front()
remove first element in l
effects
remove l[0] from l
range error occurs if l is empty
returns
return removed object
exceptions
range_error
if l is empty
template<class T> T& pop_back()
remove last element in l
effects
remove l[size()-1] from l
range error occurs if l is empty
returns
return removed object
exceptions
range_error
if l is empty
nil clear()
destroy all elements in l
effects
l=list_type()
nil resize(unsigned int size)
resize l to contain size elements
parameters
unsigned int size
new list size
effects
if size > size(), expand l by inserting nil at the end to reach a size of
size elements
if size < size(), reduce l
to first size elements
template<class T> nil resize(unsigned int size, T value)
resize l to contain size elements
parameters
unsigned int size
new list size
T value
value to be copied for expansion
effects
if size > size(), expand l by inserting copies of value at the end to reach a size of
size elements
if size < size(), reduce l
to first size elements
template<class T> T& push_front(T value)
add copy of value at the beginning of l
parameters
T value
value to be copied to new element
effects
insert copy of value into l at right before its current first element
returns
return object inserted
template<class T> T& push_back(T value)
add copy of value at the end of l
parameters
T value
value to be copied to new element
effects
insert copy of value into l at left after its current last element
returns
return object inserted
nil swap(list& x)
swap x.l with l
parameter
list& x
object to be swapped
effects
swap(l,x.l)