| | | | | |

The CSet Adaptor

  template < typename T , class C , class P = TLessThan < T > >
  class CSet
  {
  private:
    C c_;
  public:
    typedef C                          ContainerType;
    typedef typename C::ValueType      ValueType;
    typedef typename C::PredicateType  PredicateType;
    typedef CSetIterator<T,C,P>        Iterator;
    typedef CSetIterator<T,C,P>        ConstIterator;

    // element operations - modality determined by C
    Iterator  Insert  (const ValueType& t);               // insert by value
    bool      Insert  (Iterator& i, const ValueType& t);  // insert at location (checked)
    size_t    Remove  (const ValueType& t);               // remove by value
    bool      Remove  (Iterator& i);                      // remove specified item
    void      Clear   ();

    // locator operations
    Iterator  LowerBound   (const ValueType& t) const;
    Iterator  UpperBound   (const ValueType& t) const;
    Iterator  Includes     (const ValueType& t) const;
    Iterator  Begin        () const;
    Iterator  End          () const;
    Iterator  rBegin       () const;
    Iterator  rEnd         () const;

    // size operations
    bool      Empty   () const;
    size_t    Size    () const;

    // proper type
    CSet  (); // uses default predicate object
    CSet  (const CSet<T,C,P>& s);
    virtual ~CSet ();
    CSet<T,C,P>& operator  = (const CSet<T,C,P>& s);

    // 1-parameter constructor specifies predicate object
    explicit CSet  (const PredicateType& p);

    // access the predicate - cannot change it; needed by g_set algorithms
    const PredicateType& GetPredicate () const;

    // generic display
    void Display (std::ostream& os, char ofc = '\0') const;
    void Dump    (std::ostream& os, char ofc = '\0') const;
  } ; // class CSet

| | Top of Page | 7. Sets and Maps 1: Ordered - 6 of 11