• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/Common/vtkIdList.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkIdList.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00026 #ifndef __vtkIdList_h
00027 #define __vtkIdList_h
00028 
00029 #include "vtkObject.h"
00030 
00031 class VTK_COMMON_EXPORT vtkIdList : public vtkObject
00032 {
00033 public:
00034   static vtkIdList *New();
00035 
00036   void Initialize();
00037   int Allocate(const vtkIdType sz, const int strategy=0);
00038   vtkTypeRevisionMacro(vtkIdList,vtkObject);
00039   void PrintSelf(ostream& os, vtkIndent indent);
00040 
00042   vtkIdType GetNumberOfIds() {return this->NumberOfIds;};
00043   
00045   vtkIdType GetId(const vtkIdType i) {return this->Ids[i];};
00046   
00049   void SetNumberOfIds(const vtkIdType number);
00050 
00054   void SetId(const vtkIdType i, const vtkIdType vtkid) {this->Ids[i] = vtkid;};
00055 
00058   void InsertId(const vtkIdType i, const vtkIdType vtkid);
00059 
00062   vtkIdType InsertNextId(const vtkIdType vtkid);
00063 
00066   vtkIdType InsertUniqueId(const vtkIdType vtkid);
00067 
00069   vtkIdType *GetPointer(const vtkIdType i) {return this->Ids + i;};
00070 
00074   vtkIdType *WritePointer(const vtkIdType i, const vtkIdType number);
00075 
00077   void Reset() {this->NumberOfIds = 0;};
00078 
00080   void Squeeze() {this->Resize(this->NumberOfIds);};
00081 
00083   void DeepCopy(vtkIdList *ids);
00084 
00087   void DeleteId(vtkIdType vtkid);
00088 
00091   vtkIdType IsId(vtkIdType vtkid);
00092 
00095   void IntersectWith(vtkIdList& otherIds);
00096 
00097 protected:
00098   vtkIdList();
00099   ~vtkIdList();
00100 
00101   vtkIdType NumberOfIds;
00102   vtkIdType Size; 
00103   vtkIdType *Ids;
00104 
00105   vtkIdType *Resize(const vtkIdType sz);
00106 private:
00107   vtkIdList(const vtkIdList&);  // Not implemented.
00108   void operator=(const vtkIdList&);  // Not implemented.
00109 };
00110 
00111 // In-lined for performance
00112 inline vtkIdType vtkIdList::InsertNextId(const vtkIdType vtkid)
00113 {
00114   if ( this->NumberOfIds >= this->Size )
00115     {
00116     this->Resize(this->NumberOfIds+1);
00117     }
00118   this->Ids[this->NumberOfIds++] = vtkid;
00119   return this->NumberOfIds-1;
00120 }
00121 
00122 inline vtkIdType vtkIdList::IsId(vtkIdType vtkid)
00123 {
00124   vtkIdType *ptr, i;
00125   for (ptr=this->Ids, i=0; i<this->NumberOfIds; i++, ptr++)
00126     {
00127     if ( vtkid == *ptr )
00128       {
00129       return i;
00130       }
00131     }
00132   return (-1);
00133 }
00134 
00135 #endif

Generated by  doxygen 1.7.1