public:
List constructor. Constructs an empty list in O(1) time.
List()
List destructor. Internally calls delete_shallow. Destructor
is virtual in case someone decides to inherit from the List<X> class.
Takes O(n) time.
virtual ~List();
Calls operator delete on all private_data and node pointers.
The result is an empty list. Takes O(n) time.
void delete_deep();
Calls operator delete on all node pointers.
The result is an empty list. Take O(n) time.
void delete_shallow();
Returns a pointer to the start of the list. Takes O(1) time.
Node<X>* get_first();
Returns a pointer to the end of the list. Takes O(1) time.
Node<X>* get_last();
Const versions of the previous two methods. Each method takes O(1) time.
const Node<X>* get_first_const() const;
const Node<X>* get_last_const() const;
Chains x onto the start of the list. Takes O(1) time.
void add_to_start(X* x);
Chains x onto the end of the list. Takes O(1) time.
void add_to_end(X* x);
Returns the length of the list. Takes O(1) time.
int get_length() const;
Returns whether or not the list has been changed since construction
or the last call to clear_dirty(). Takes O(1) time.
bool get_dirty() const;
Allows the client to declare the list as unchanged. Takes O(1) time.
void clear_dirty();
Reverses the order of the list. Takes O(n) time.
void reverse();
|