Class:nsTDeque: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 21: | Line 21: | ||
| | ||
/** | /** | ||
* | * @returns | ||
* The number of elements in the deque. | |||
*/ | */ | ||
PRUint32 Length(); // or Count() ? | PRUint32 Length(); // or Count() ? | ||
| |||
/** | |||
* @returns | |||
* PR_TRUE if the deque contains no elements and PR_FALSE otherwise. | |||
*/ | |||
PRBool IsEmpty(); | |||
| | ||
/** | /** | ||
* Adds a new element to the front of the deque. | * Adds a new element to the front of the deque. | ||
* @param obj | * @param obj | ||
* | * The object to be added. | ||
*/ | */ | ||
void PushFront(const T& obj); | void PushFront(const T& obj); | ||
| | ||
/** | /** | ||
* Adds a new element to the front of the deque. | * Adds a new element using T's default constructor to the front of the | ||
* @returns | * deque. | ||
* @returns | |||
* The address of the newly added element or null if the object | |||
* could not be allocated. | |||
*/ | */ | ||
T* PushFront(); | T* PushFront(); | ||
| | ||
/** | |||
* Adds a new element to the back of the deque. | |||
* @param obj | |||
* The object to be added. | |||
*/ | |||
void PushBack(const T& obj); | void PushBack(const T& obj); | ||
| |||
/** | |||
* Adds a new element using T's default constructor to the back of the | |||
* deque. | |||
* @returns | |||
* The address of the newly added element or null if the object | |||
* could not be allocated. | |||
*/ | |||
T* PushBack(); | T* PushBack(); | ||
| |||
/** | |||
* @returns | |||
* A const reference to the element at the front of the deque. | |||
* It is an error to call this method on an empty deque. | |||
*/ | |||
const T& Front() const; | const T& Front() const; | ||
| |||
/** | |||
* @returns | |||
* A reference to the element at the front of the deque. | |||
* It is an error to call this method on an empty deque. | |||
*/ | |||
T& Front(); | T& Front(); | ||
| |||
/** | |||
* @returns | |||
* A const reference to the element at the back of the deque. | |||
* It is an error to call this method on an empty deque. | |||
*/ | |||
const T& Back() const; | const T& Back() const; | ||
| |||
/** | |||
* @returns | |||
* A reference to the element at the back of the deque. | |||
* It is an error to call this method on an empty deque. | |||
*/ | |||
T& Back(); | T& Back(); | ||
| |||
/** | |||
* Removes the element at the front of the deque. This method | |||
* has no effect if the deque is empty. | |||
*/ | |||
void PopFront(); | void PopFront(); | ||
| |||
/** | |||
* Removes the element at the back of the deque. This method | |||
* has no effect if the deque is empty. | |||
*/ | |||
void PopBack(); | void PopBack(); | ||
}; | }; | ||
Revision as of 17:51, 15 June 2006
template <class T>
class nsTDeque {
public:
/**
* @constructor
* @param objectsPerPage
* Optional parameter that specifies the number of objects per page
* in the deque.
*/
explicit nsTDeque(PRUint32 objectsPerPage = 32);
/**
* @destructor
*/
~nsTDeque();
/**
* Clear all elements from the deque.
*/
void Clear();
/**
* @returns
* The number of elements in the deque.
*/
PRUint32 Length(); // or Count() ?
/**
* @returns
* PR_TRUE if the deque contains no elements and PR_FALSE otherwise.
*/
PRBool IsEmpty();
/**
* Adds a new element to the front of the deque.
* @param obj
* The object to be added.
*/
void PushFront(const T& obj);
/**
* Adds a new element using T's default constructor to the front of the
* deque.
* @returns
* The address of the newly added element or null if the object
* could not be allocated.
*/
T* PushFront();
/**
* Adds a new element to the back of the deque.
* @param obj
* The object to be added.
*/
void PushBack(const T& obj);
/**
* Adds a new element using T's default constructor to the back of the
* deque.
* @returns
* The address of the newly added element or null if the object
* could not be allocated.
*/
T* PushBack();
/**
* @returns
* A const reference to the element at the front of the deque.
* It is an error to call this method on an empty deque.
*/
const T& Front() const;
/**
* @returns
* A reference to the element at the front of the deque.
* It is an error to call this method on an empty deque.
*/
T& Front();
/**
* @returns
* A const reference to the element at the back of the deque.
* It is an error to call this method on an empty deque.
*/
const T& Back() const;
/**
* @returns
* A reference to the element at the back of the deque.
* It is an error to call this method on an empty deque.
*/
T& Back();
/**
* Removes the element at the front of the deque. This method
* has no effect if the deque is empty.
*/
void PopFront();
/**
* Removes the element at the back of the deque. This method
* has no effect if the deque is empty.
*/
void PopBack();
};