From f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 03:49:53 +0000 Subject: Ok, no code is left in src, it's all in src/old. We'll gradually move code back into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier. --- src/ringlist.h | 112 --------------------------------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 src/ringlist.h (limited to 'src/ringlist.h') diff --git a/src/ringlist.h b/src/ringlist.h deleted file mode 100644 index bc069f3..0000000 --- a/src/ringlist.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef RINGLIST_H -#define RINGLIST_H - -#include "list.h" - -/** - * A RingList or Ring Buffer implementation. This is a list that never grows in - * size once it is created, but instead once it is full new items added to the - * RingList replace the oldest items and the zero-index is virtually shifted. - * Since no data is actually moved when zero-index moves, this is very - * efficient. - *
- * The items removed are not actually deleted by the RingList, so instead they - * are first moved into a temporary "Push Buffer" that can be accessed so that - * elements pushed off the edge of the RingList can be accessed for cleanup. - *@author Mike Buland - */ -class RingList : public List -{ -public: - /** - * Construct a RingList with a fixed initial size. This size never changes - * unless setSize is called later during normal operation. - *@param nInitSize The number of elements to allocate. - */ - RingList( int nInitSize ); - - /** - * Clean up the data structures, but not the contained elements. - */ - virtual ~RingList(); - - /** - * Get an element at the specified index. - *@param nIndex The index of the element to retreive. - *@returns A pointer to the requested element, or NULL if the element is - * not found or not initialized yet. - */ - void *getAt( int nIndex ); - - /** - * Append an element to the end of the list, overwriting the begining if - * necesarry. - *@param pData The pointer to append to the RingList. - */ - void append( void *pData ); - - /** - * Insert an element before another in the RingList, pushing all after it - * down the list. - *@param pData The data to insert. - *@param nPos The position that new the element should occupy in the list. - */ - void insertBefore( void *pData, int nPos = 0 ); - - /** - * Get the size of the array. - */ - int getSize(); - - /** - * Is the RingList empty? - *@returns True if it is empty, false otherwise. - */ - bool isEmpty(); - - /** - * Delete an element in the list, moving all later elements down one index. - *@param nIndex The index of the element to delete. - */ - void deleteAt( int nIndex ); - - /** - * Remove all elements from the RingList. - */ - void empty(); - - /** - * Set a new size for the RingList. Be careful with this one, if shrinking - * this may quietly create a memory leak. - *@param nNewSize The new size to set the RingList to. - *@todo Either fix this memory leak somehow or remove this function. - */ - void setSize( int nNewSize ); - - /** - * Set a specific element to a new value. - *@param nIndex The zero-based index to change the value of. - *@param pData The data to put at the location specified by nIndex. - */ - void setAt( int nIndex, void *pData ); - - /** - * Retrieve the contents of the push buffer. This is the data that is - * pushed off the end of the array if you append data and the list is full. - * This should be checked after every append operation to be sure there - * isn't anything that needs deleting. - *@returns The last value pushed off the RingList, or NULL if nothing was - * pushed off. - */ - void *getPushBuf(); - -private: - int nFirstIndex; /**< The index to be translated as zero. */ - int nRealLength; /**< The Amount of storage space available. */ - int nDataLength; /**< The number of elements filled in. */ - void **apData; /**< The actual data storage. */ - void *pPushBuf; /**< The push buffer. */ - -}; - -#endif -- cgit v1.2.3