contrib/rpl/rgrl/rgrl_set_of.h
Go to the documentation of this file.
00001 #ifndef rgrl_set_of_h_
00002 #define rgrl_set_of_h_
00003 
00004 //:
00005 // \file
00006 // \author Amitha Perera
00007 // \date   Feb 2003
00008 
00009 #include <vcl_vector.h>
00010 #include <vcl_cstddef.h>
00011 
00012 //: A collection of objects
00013 //
00014 // This is a std::vector with a subset of the interface. The idea is
00015 // to allow easy change of underlying data structures if it proves
00016 // necessary later on.
00017 //
00018 template<typename T>
00019 class rgrl_set_of
00020 {
00021 public:
00022   //: Construct an empty set
00023   rgrl_set_of();
00024 
00025   // compiler generated copy and assignment are good enough.
00026 
00027   //: Add a match set to the collection.
00028   void
00029   push_back( T const& item );
00030 
00031   //: The number of match sets in the collection.
00032   vcl_size_t
00033   size() const;
00034 
00035   //:
00036   T const& operator[]( unsigned i ) const;
00037 
00038   //:
00039   T& operator[]( unsigned i );
00040 
00041   //: Reset to an empty collection
00042   void
00043   clear();
00044 
00045   //: fill current set 
00046   void fill( T const& item );
00047   
00048   //: Same idea as std::vector::resize()
00049   void
00050   resize( unsigned n );
00051 
00052   //: is it an empty set?
00053   bool empty() const;
00054   
00055 private:
00056   vcl_vector< T > data_;
00057 };
00058 
00059 #endif // rgrl_set_of_h_