IcePairs.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /**
  3. * Contains a simple pair class.
  4. * \file IcePairs.h
  5. * \author Pierre Terdiman
  6. * \date January, 13, 2003
  7. */
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. // Include Guard
  11. #ifndef __ICEPAIRS_H__
  12. #define __ICEPAIRS_H__
  13. //! A generic couple structure
  14. struct ICECORE_API Pair
  15. {
  16. inline_ Pair() {}
  17. inline_ Pair(udword i0, udword i1) : id0(i0), id1(i1) {}
  18. udword id0; //!< First index of the pair
  19. udword id1; //!< Second index of the pair
  20. };
  21. class ICECORE_API Pairs : private OPC_Container
  22. {
  23. public:
  24. // Constructor / Destructor
  25. Pairs() {}
  26. ~Pairs() {}
  27. inline_ udword GetNbPairs() const { return GetNbEntries()>>1; }
  28. inline_ const Pair* GetPairs() const { return (const Pair*)GetEntries(); }
  29. inline_ const Pair* GetPair(udword i) const { return (const Pair*)&GetEntries()[i+i]; }
  30. inline_ BOOL HasPairs() const { return IsNotEmpty(); }
  31. inline_ void ResetPairs() { Reset(); }
  32. inline_ void DeleteLastPair() { DeleteLastEntry(); DeleteLastEntry(); }
  33. inline_ void AddPair(const Pair& p) { Add(p.id0).Add(p.id1); }
  34. inline_ void AddPair(udword id0, udword id1) { Add(id0).Add(id1); }
  35. };
  36. #endif // __ICEPAIRS_H__