aboutsummaryrefslogtreecommitdiff
path: root/PDContainer/include/HSet.h
blob: 231b9096146e73064fcccd71f63364b5a90cff2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// *********************(c)*2004*********************>
// -holzilib--holzilib--holzilib--holzilib--holzilib->
// ++++PD-External++by+Georg+Holzmann++grh@gmx.at++++>
//
// PDContainer: 
// this is a port of the containers from the C++ STL
// (Standard Template Library)
// for usage see the documentation and PD help files
// for license see readme.txt
//
// HSet.h


#ifndef _h_set_h__
#define _h_set_h__

#include "include/SimpleBase.h"
#include <set>

using std::set;

//---------------------------------------------------
/* this is the class of the set
 */
class HSet : 
public SimpleBase< set<Element>, set<Element>::iterator >
{

 private:

  /* Copy Construction is not allowed
   */
  HSet(const HSet &src)
    { }

  /* assignement operator is not allowed
   */
  const HSet& operator = (const HSet&)
    { return *this; }

 public:

  /* Constructor
   * no namespace
   */
  HSet()
    { dataname_ = "h_set"; }

  /* Constructor
   * with a namespace
   */
  HSet(string h_namespace)
    {
      dataname_ = "h_set";
      setNamespace(h_namespace); 
    }

  /* Destructor
   */  
  virtual ~HSet() { }

  /* add an element
   */
  virtual void add(Element key)
    {  data_[h_namespace_].insert(key);  }

  /* look if the element is set
   * returns 1 if it is set 
   * 0 if it isn't set
   */
  virtual int get(const Element &key) const
    {  return (data_[h_namespace_].find(key) 
	       != data_[h_namespace_].end());  }

  /* removes an element from the container
   */
  virtual void remove(const Element &key) const
    {  data_[h_namespace_].erase(key);  }
};


#endif   // _h_set_h__