00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkLinkedList.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00018 #ifndef __vtkLinkedList_h 00019 #define __vtkLinkedList_h 00020 00021 #include "vtkAbstractList.h" 00022 00023 template <class DType> class vtkLinkedListNode; 00024 template <class DType> class vtkLinkedListIterator; 00025 00026 template <class DType> 00027 class vtkLinkedList : public vtkAbstractList<DType> 00028 { 00029 friend class vtkLinkedListIterator<DType>; 00030 virtual const char* GetClassNameInternal() const { return "vtkLinkedList"; } 00031 00032 public: 00033 typedef vtkAbstractList<DType> Superclass; 00034 typedef vtkLinkedListIterator<DType> IteratorType; 00035 00036 static vtkLinkedList<DType> *New(); 00037 00040 vtkLinkedListIterator<DType> *NewIterator(); 00041 00043 int AppendItem(DType a); 00044 00046 int PrependItem(DType a); 00047 00049 int InsertItem(vtkIdType loc, DType a); 00050 00053 int SetItem(vtkIdType loc, DType a); 00054 00057 void SetItemNoCheck(vtkIdType loc, DType a); 00058 00060 int RemoveItem(vtkIdType id); 00061 00063 int GetItem(vtkIdType id, DType& ret); 00064 00067 int FindItem(DType a, vtkIdType &res); 00068 00070 00073 int FindItem(DType a, 00074 vtkAbstractListCompareFunction(DType, compare), 00075 vtkIdType &res); 00077 00081 vtkIdType GetNumberOfItems() const { return this->NumberOfItems; } 00082 00086 vtkIdType GetSize() const { return this->NumberOfItems; } 00087 00089 void RemoveAllItems(); 00090 00093 int SetSize(vtkIdType ) { return VTK_ERROR; } 00094 00096 void DebugList(); 00097 00098 protected: 00099 vtkLinkedList() { 00100 this->Head = 0; this->Tail = 0; 00101 this->NumberOfItems = 0; 00102 } 00103 virtual ~vtkLinkedList(); 00104 00106 vtkLinkedListNode<DType>* FindNode(vtkIdType i); 00107 00108 vtkIdType NumberOfItems; 00109 vtkLinkedListNode<DType> *Head; 00110 vtkLinkedListNode<DType> *Tail; 00111 00112 private: 00113 vtkLinkedList(const vtkLinkedList<DType>&); // Not implemented 00114 void operator=(const vtkLinkedList<DType>&); // Not implemented 00115 }; 00116 00117 #ifdef VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION 00118 #include "vtkLinkedList.txx" 00119 #endif 00120 00121 #endif 00122 00123 00124