#include <ace/Containers.h>
template<class T> class ACE_Double_Linked_List {
public:
friend class ACE_Double_Linked_List_Iterator_Base<T>;
friend class ACE_Double_Linked_List_Iterator<T>;
friend class ACE_Double_Linked_List_Reverse_Iterator<T>;
typedef ACE_Double_Linked_List_Iterator<T> ITERATOR;
typedef ACE_Double_Linked_List_Reverse_Iterator<T> REVERSE_ITERATOR;ACE_Double_Linked_List (ACE_Allocator *alloc = 0);
ACE_Double_Linked_List (ACE_Double_Linked_List<T> &);
void operator= (ACE_Double_Linked_List<T> &);
~ACE_Double_Linked_List (void);
int is_empty (void) const;
int is_full (void) const;
T *insert_tail (T *new_item);
T *insert_head (T *new_item);
T* delete_head (void);
T *delete_tail (void);
void reset (void);
int get (T *&item, size_t slot = 0);
size_t size (void) const;
void dump (void) const;
int remove (T *n);
ACE_ALLOC_HOOK_DECLARE;
protected:
void delete_nodes (void);
void copy_nodes (ACE_Double_Linked_List<T> &);
void init_head (void);
int insert_element (T *new_item, int before = 0, T *old_item = 0);
int remove_element (T *item);
T *head_;
size_t size_;
ACE_Allocator *allocator_;
};
ACE_Unbounded_Queue
except that it allows removing
of a specific element from a specific location.
Notice that this class is an implementation of a very simply data structure.is *NOT* a container class. You can use the class to implement other contains classes but it is *NOT* a general purpose container class.
The parameter class *MUST* has members T* prev and T* next and users of this class are responsible to follow the general rules of using double-linked lists to maintaining the list integrities.
If you need a double linked container class, check out the DLList class in this file.
ACE_Double_Linked_List (ACE_Allocator *alloc = 0);
ACE_Double_Linked_List (ACE_Double_Linked_List<T> &);
void operator= (ACE_Double_Linked_List<T> &);
~ACE_Double_Linked_List (void);
int is_empty (void) const;
int is_full (void) const;
T *insert_tail (T *new_item);
new_item
to the tail of the list. Returns the new item
that was inserted.
T *insert_head (T *new_item);
new_item
to the head of the list.Returns the new item that
was inserted.
T* delete_head (void);
item
in the list. Returns
internal node's address on success, 0 if the queue was empty.
This method will *not* free the internal node.
T *delete_tail (void);
item
in the list. Returns
internal nodes's address on success, 0 if the queue was
empty. This method will *not* free the internal node.
void reset (void);
ACE_Double_Linked_List
to be empty.
Notice that since no one is interested in the items within,
This operation will delete all items.
int get (T *&item, size_t slot = 0);
slot
th element in the set. Returns -1 if the element
isn't in the range {0..size
- 1}, else 0.
size_t size (void) const;
void dump (void) const;
int remove (T *n);
ACE_ALLOC_HOOK_DECLARE;