NAME
ACE_Double_Linked_List - A double-linked list implementation.
SYNOPSIS
#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_;
};
DESCRIPTION
This implementation of an unbounded double-linked list uses a circular linked list with a dummy node. It is pretty much like the 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.
Initialization and termination methods.
ACE_Double_Linked_List (ACE_Allocator *alloc = 0);
construction. Use user specified allocation strategy if specified.
ACE_Double_Linked_List (ACE_Double_Linked_List<T> &);
Copy constructor.
void operator= (ACE_Double_Linked_List<T> &);
Assignment operator.
~ACE_Double_Linked_List (void);
Destructor.
Check boundary conditions.
int is_empty (void) const;
Returns 1 if the container is empty, otherwise returns 0.
int is_full (void) const;
Returns 1 if the container is full, otherwise returns 0.
Classic queue operations.
T *insert_tail (T *new_item);
Adds new_item to the tail of the list. Returns the new item that was inserted.
T *insert_head (T *new_item);
Adds new_item to the head of the list.Returns the new item that was inserted.
T* delete_head (void);
Removes and returns the first 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);
Removes and returns the last 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.
Additional utility methods.
void reset (void);
Reset the 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);
Get the slotth element in the set. Returns -1 if the element isn't in the range {0..size - 1}, else 0.
size_t size (void) const;
The number of items in the queue.
void dump (void) const;
Dump the state of an object.
int remove (T *n);
Use DNode address directly.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
AUTHOR
Doug Schmidt
Initialization and termination methods.
Check boundary conditions.
Classic unordered set operations.
LIBRARY
ace