| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#pragma once |
| 16 |
#ifndef VHACD_CIRCULAR_LIST_H |
| 17 |
#define VHACD_CIRCULAR_LIST_H |
| 18 |
#include <stdlib.h> |
| 19 |
namespace VHACD { |
| 20 |
|
| 21 |
template <typename T> |
| 22 |
class CircularListElement { |
| 23 |
public: |
| 24 |
T& GetData() { return m_data; } |
| 25 |
const T& GetData() const { return m_data; } |
| 26 |
CircularListElement<T>*& GetNext() { return m_next; } |
| 27 |
CircularListElement<T>*& GetPrev() { return m_prev; } |
| 28 |
const CircularListElement<T>*& GetNext() const { return m_next; } |
| 29 |
const CircularListElement<T>*& GetPrev() const { return m_prev; } |
| 30 |
|
| 31 |
CircularListElement(const T& data) { m_data = data; } |
| 32 |
CircularListElement(void) {} |
| 33 |
|
| 34 |
~CircularListElement(void) {} |
| 35 |
private: |
| 36 |
T m_data; |
| 37 |
CircularListElement<T>* m_next; |
| 38 |
CircularListElement<T>* m_prev; |
| 39 |
|
| 40 |
CircularListElement(const CircularListElement& rhs); |
| 41 |
}; |
| 42 |
|
| 43 |
template <typename T> |
| 44 |
class CircularList { |
| 45 |
public: |
| 46 |
CircularListElement<T>*& GetHead() { return m_head; } |
| 47 |
const CircularListElement<T>* GetHead() const { return m_head; } |
| 48 |
bool IsEmpty() const { return (m_size == 0); } |
| 49 |
size_t GetSize() const { return m_size; } |
| 50 |
const T& GetData() const { return m_head->GetData(); } |
| 51 |
T& GetData() { return m_head->GetData(); } |
| 52 |
bool Delete(); |
| 53 |
bool Delete(CircularListElement<T>* element); |
| 54 |
CircularListElement<T>* Add(const T* data = 0); |
| 55 |
CircularListElement<T>* Add(const T& data); |
| 56 |
bool Next(); |
| 57 |
bool Prev(); |
| 58 |
void Clear() |
| 59 |
{ |
| 60 |
while (Delete()) |
| 61 |
; |
| 62 |
}; |
| 63 |
const CircularList& operator=(const CircularList& rhs); |
| 64 |
|
| 65 |
CircularList() |
| 66 |
{ |
| 67 |
m_head = 0; |
| 68 |
m_size = 0; |
| 69 |
} |
| 70 |
CircularList(const CircularList& rhs); |
| 71 |
|
| 72 |
~CircularList(void) { Clear(); }; |
| 73 |
private: |
| 74 |
CircularListElement<T>* m_head; |
| 75 |
size_t m_size; |
| 76 |
}; |
| 77 |
} |
| 78 |
#include "vhacdCircularList.inl" |
| 79 |
#endif |