CodeSonar C++ API
[For improved navigation, enable JavaScript.]
cs_set.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, an unpublished work by CodeSecure, Inc.
3  * ALL RIGHTS RESERVED
4  *
5  * Copyright (c) 2013-2023, an unpublished work by GrammaTech, Inc.
6  * ALL RIGHTS RESERVED
7  *
8  * This software is furnished under a license and may be used and
9  * copied only in accordance with the terms of such license and the
10  * inclusion of the above copyright notice. This software or any
11  * other copies thereof may not be provided or otherwise made
12  * available to any other person. Title to and ownership of the
13  * software is retained by CodeSecure, Inc.
14  */
15 
16 #ifndef CS_SET_HPP
17 #define CS_SET_HPP
18 
19 #include "cs_utility.h"
20 /* Provide an STL-set-compatible interface to the various set types. */
21 #include "cs_iterator_adapter.hpp"
22 
25 namespace cs{
26  template<typename elt> class set_impl;
27  template<typename elt> class set_iterator_policy;
28  template<typename elt> class mutable_set;
29  template<typename elt> class immutable_set;
30  template<typename derived> class set_mixin;
31  /* Do not define a default instantiation for set_mixin... SWIG has
32  * a tendency to silently use it when it should not.
33  */
34 
36  class set_kind{
37  typedef std::pair<csuint32, csuint32> int_pair_t;
38  CS_ENUM_BOILERPLATE_UB(set_kind, cs_set_kind,
39  check(cs_set_kind_name(
40  inner, &rv)),
41  cs_set_kind_count);
42 #include "cs_set_kind_decls.hpp"
43  };
44  CS_ENUM_BOILERPLATE_FRIENDS(set_kind,
45  friend class mutable_set<symbol>;
46  friend class mutable_set<point>;
47  friend class mutable_set<basic_block>;
48  friend class mutable_set<set_kind::int_pair_t>;,
49  cs
50  )
51 #include "cs_set_kind_defs.hpp"
52 
53  // Don't hide from doxygen
54 
55  template<typename T>
56  class intrusive
57  {
58  T *p;
59  public:
60  intrusive()
61  : p(0){}
62  intrusive(T *_p)
63  : p(_p)
64  { p->incref(); }
65  intrusive(const intrusive &other)
66  : p(other.p)
67  { p->incref(); }
68  ~intrusive()
69  { if( p ) p->decref(); }
70  void
71  swap(intrusive& other)
72  { std::swap(p, other.p); }
73  T &operator*() const
74  { return *p; }
75  T *operator->() const
76  { return p; }
77  intrusive&
78  operator=(intrusive other)
79  {
80  swap(other);
81  return *this;
82  }
83  };
84 }
85 
86 #ifndef SWIG
87 namespace std{
89  template<typename T>
90  inline void
91  swap(cs::intrusive<T>& __x, cs::intrusive<T>& __y)
92  { __x.swap(__y); }
93 }
94 #endif
95 
96 namespace cs{
97 
102  template<typename elt>
103  class immutable_set
104  {
106  friend class cglue< immutable_set<elt> >;
108  immutable_set();
109  typedef set_impl<elt> impl;
110  intrusive<impl> inner;
111  public:
113  typedef elt key_type;
114 
116  typedef elt value_type;
117 
119  typedef elt *pointer;
120 
122  typedef const elt *const_pointer;
123 
125  typedef elt &reference;
126 
128  typedef const elt &const_reference;
129 
131  typedef iterator_adapter<set_iterator_policy<elt> > iterator;
132 
134  typedef iterator const_iterator;
135 
137  typedef size_t size_type;
138 
139  private:
140  typedef typename impl::ctype ctype;
141 
142  immutable_set(ctype s, bool _frozen):
143  inner(new impl(s, _frozen)){}
144 
145  ctype unwrap() const
146  { return inner->unwrap(); }
147 
148  public:
149 
151  immutable_set(const immutable_set& other): inner(other.inner) { }
152 
155  immutable_set&
156  operator=(immutable_set other)
157  {
158  swap(other);
159  return *this;
160  }
161 
162 #if !defined(SWIGPYTHON) || !defined(SWIG)
163 
169  iterator
170  begin() const
171  { return iterator(inner); }
172 
177  iterator
178  end() const
179  { return iterator(); }
180 
186  iterator
187  cbegin() const
188  { return iterator(inner); }
189 
195  iterator
196  cend() const
197  { return iterator(); }
198 #endif
199 
203  bool
204  empty() const
205  { return inner->empty(); }
206 
207 
211  size_type
212  size() const
213  { return inner->size(); }
214 
216  void
217  swap(immutable_set& other)
218  { std::swap(inner, other.inner); }
219 
220 #if !defined(SWIGPYTHON) || !defined(SWIG)
221 
229  size_type
230  count(const elt& e) const
231  { return inner->member(cglue<elt>::unwrap(e))?1:0; }
232 
233 
241  const_iterator
242  find(const elt& e) const
243  {
244  return inner->member(cglue<elt>::unwrap(e))
245  ? iterator(cglue<elt>::unwrap(e))
246  : iterator();
247  }
248 #endif
249 
253  CS_BOILERPLATE_HASH_TYPE hash() const
254  { return inner->hash(); }
255 
259  std::vector<elt> to_vector() const
260  {
261  std::vector<elt> v;
262  v.reserve(size());
263  for( const_iterator it = cbegin(); it != cend(); ++it )
264  v.push_back(*it);
265  return v;
266  }
267 
268  private:
270  void print(std::ostream &out) const
271  {
272  out << "{";
273  size_t i = 0;
274  for( const_iterator it = cbegin(); it != cend(); ++it )
275  {
276  switch( i )
277  {
278  case 3:
279  out << ", ";
280  out << (size() - i)
281  << " more...";
282  goto really_break;
283  case 2:
284  case 1:
285  out << ", ";
286  case 0:
287  ostream_helper(*it, out);
288  break;
289  }
290  ++i;
291  }
292  really_break:
293  out << "}";
294  }
295 
296  public:
301  std::string as_string() const
302  {
303  std::stringstream buf;
304  print(buf);
305  return buf.str();
306  }
307 
313  std::string as_repr() const
314  {
315  std::stringstream buf;
316  buf << CS_AS_REPR_PREFIX
317  << impl::type_name()
318  << " ";
319  print(buf);
320  buf << CS_AS_REPR_SUFFIX;
321  return buf.str();
322  }
323 
324  /* swig produces a nicer interface if all operators are member
325  * functions.
326  */
327 #ifdef SWIG_BUILD
328 #if defined(SWIGPYTHON) && defined(SWIG)
329  %extend{
330  bool __contains__(const elt& e) const
331  { return $self->count(e) != 0; }
332 
333  iterator __iter__() const
334  { return $self->cbegin(); }
335  };
336 #endif
337 
338  bool operator==(const immutable_set &other) const
339  { return inner->equals(*other.inner); }
340 
341  bool operator!=(const immutable_set &other) const
342  { return !(*this == other); }
343 #else
344 
345  template<typename _impl1>
346  friend bool
347  operator==(const immutable_set<_impl1>&, const immutable_set<_impl1>&);
349 #endif
350  };
351 
352  /* swig doesn't do what we want with friend functions */
353 #ifndef SWIG
354 
362  template<typename _Impl>
363  inline bool
364  operator==(const immutable_set<_Impl>& __x,
365  const immutable_set<_Impl>& __y)
366  { return __x.inner->equals(__y.inner); }
367 
377  template<typename _Impl>
378  inline bool
379  operator!=(const immutable_set<_Impl>& __x,
380  const immutable_set<_Impl>& __y)
381  { return !(__x == __y); }
382 }
383 namespace std{
384  template<typename _Impl>
385  inline void
386  swap(cs::immutable_set<_Impl>& __x, cs::immutable_set<_Impl>& __y)
387  { __x.swap(__y); }
388 }
389 namespace cs{
390 #endif
391 
396  template<typename elt>
397  class mutable_set: public set_mixin<mutable_set<elt> >
398  {
399  friend class cglue< mutable_set<elt> >;
400  typedef set_impl<elt> impl;
401  typedef set_iterator_policy<elt> iterator_policy;
402  intrusive<impl> inner;
403  public:
405  typedef elt key_type;
406 
408  typedef elt value_type;
409 
411  typedef elt *pointer;
412 
414  typedef const elt *const_pointer;
415 
417  typedef elt &reference;
418 
420  typedef const elt &const_reference;
421 
423  typedef iterator_adapter<iterator_policy> iterator;
424 
426  typedef iterator const_iterator;
427 
429  typedef size_t size_type;
430 
432  typedef typename impl::ctype ctype;
435  /* fork() will take care of doing an actual deep copy, if it
436  * becomes necessary.
437  */
439  mutable_set(const mutable_set& other): inner(other.inner) { }
440 
443  mutable_set&
444  operator=(mutable_set other)
445  {
446  swap(other);
447  return *this;
448  }
449 
450  private:
451  ctype unwrap() const
452  {
453  return inner->unwrap();
454  }
455 
456  public:
465  set_kind kind() const
466  {
467  return cglue<set_kind>::wrap(inner->kind());
468  }
469 
470 #if !defined(SWIGPYTHON) || !defined(SWIG)
471 
477  iterator
478  begin() const
479  { return iterator(inner); }
480 
486  iterator
487  end() const
488  { return iterator(); }
489 
495  iterator
496  cbegin() const
497  { return iterator(inner); }
498 
504  iterator
505  cend() const
506  { return iterator(); }
507 #endif
508 
509 
513  bool
514  empty() const
515  { return inner->empty(); }
516 
517 
521  size_type
522  size() const
523  { return inner->size(); }
524 
526  void
527  swap(mutable_set& other)
528  { std::swap(inner, other.inner); }
529 
530 #if !defined(SWIGPYTHON) || !defined(SWIG)
531 
539  size_type
540  count(const elt& e) const
541  { return inner->member(cglue<elt>::unwrap(e))?1:0; }
542 
550  const_iterator
551  find(const elt& e) const
552  {
553  return inner->member(cglue<elt>::unwrap(e))
554  ? iterator(cglue<elt>::unwrap(e))
555  : iterator();
556  }
557 #endif
558 
562  CS_BOILERPLATE_HASH_TYPE hash() const
563  { return inner->hash(); }
564 
565  /* Alternate, slower implementation:
566  std::vector<elt> to_vector() const
567  { return std::vector<elt>(cbegin(), cend()); }
568  */
569 
573  std::vector<elt> to_vector() const
574  {
575  std::vector<elt> v;
576  v.reserve(size());
577  for( const_iterator it = cbegin(); !it.at_end(); ++it )
578  v.push_back(*it);
579  return v;
580  }
581 
583  mutable_set(): inner(new impl()){}
584 
596  mutable_set(set_kind k): inner(new impl(cglue<set_kind>::unwrap(k))){}
597 
598  private:
599  mutable_set(ctype s,
600  bool frozen)
601  : inner(new impl(s, frozen)){}
602 
603  ctype multi_union(const std::vector<mutable_set<impl> > &v)
604  {
605  ctype *csets = new ctype[v.size()];
606  size_t i;
607  ctype rv;
608  cs_result r;
609  memset( &rv, 0, sizeof(rv) );
610  for( i = 0; i < v.size(); i++ )
611  csets[i] = v[i].unwrap();
612  r = impl::multi_union(csets, v.size(), rv);
613  delete[] csets;
614  check(r);
615  return rv;
616  }
617  public:
618 #ifndef SWIG
619  /* SWIG chokes on this vector type, so swig users will have to
620  * live without it.
621  */
624  mutable_set(const std::vector<mutable_set<impl> > &v)
625  : inner(new impl(multi_union(v), false)){}
626 #endif
627 
632  mutable_set(const std::vector<elt> &v)
633  : inner(new impl())
634  {
635  size_t i;
636  for( i = 0; i < v.size(); i++ )
637  add(v[i]);
638  }
639 
640  private:
641  void fork()
642  {
643  if( inner->shared() )
644  {
645  /* An iterator is using it... We can't mutate it, but
646  * we can create a copy and mutate that.
647  */
648  inner = new impl(*inner);
649  }
650  }
651  public:
652 
653  /* Like insert, but doesn't return the iterator. */
661  bool
662  add(const elt& v)
663  {
664  fork();
665  cs_result r = inner->put(cglue<elt>::unwrap(v));
666  /* The order of this container isn't really well-defined,
667  * so return an iterator that just iterates over the one
668  * value.
669  */
670  if( r == CS_ELEMENT_ALREADY_PRESENT )
671  return false;
672  check(r);
673  return true;
674  }
675 
676 #ifndef SWIG
677 
687  std::pair<iterator, bool>
688  insert(const elt& v)
689  {
690  /* The order of this container isn't really well-defined,
691  * so return an iterator that just iterates over the one
692  * value.
693  */
694  return std::pair<iterator, bool>(
695  iterator(cglue<elt>::unwrap(v)),
696  add(v));
697  }
698 #endif
699 
700  /* python prefers remove/discard naming convention */
701 #if defined(SWIG) && defined(SWIGPYTHON)
702  %rename(_erase) erase;
703 #endif
704 
712  size_type
713  erase(const elt& v)
714  {
715  fork();
716  cs_result r = inner->del(cglue<elt>::unwrap(v));
717  if( r == CS_ELEMENT_NOT_PRESENT )
718  return 0;
719  check(r);
720  return 1;
721  }
722 
727  void
728  clear()
729  { inner = new impl(); }
730 
731 #if defined(SWIG) && defined(SWIGPYTHON)
732  %rename(_union) union_;
733 #endif
734 
744  mutable_set union_(const mutable_set& b) const
745  { return mutable_set(inner->union_(*b.inner), false); }
746 
747 
756  void union_p(const mutable_set& b)
757  {
758  fork();
759  inner->union_p(*b.inner);
760  }
761 
762 
772  mutable_set intersect(const mutable_set& b) const
773  { return mutable_set(inner->intersect(*b.inner), false); }
774 
775 
785  mutable_set difference(const mutable_set& b) const
786  { return mutable_set(inner->difference(*b.inner), false); }
787 
788  private:
791  void print(std::ostream &out) const
792  {
793  out << "{";
794  size_t i = 0;
795  for( const_iterator it = cbegin(); it != cend(); ++it )
796  {
797  switch( i )
798  {
799  case 3:
800  out << ", ";
801  out << (size() - i)
802  << " more...";
803  goto really_break;
804  case 2:
805  case 1:
806  out << ", ";
807  case 0:
808  ostream_helper(*it, out);
809  break;
810  }
811  ++i;
812  }
813  really_break:
814  out << "}";
815  }
816 
817  public:
819  std::string as_string() const
820  {
821  std::stringstream buf;
822  print(buf);
823  return buf.str();
824  }
825 
829  std::string as_repr() const
830  {
831  std::stringstream buf;
832  buf << CS_AS_REPR_PREFIX
833  << impl::type_name()
834  << " ";
835  print(buf);
836  buf << CS_AS_REPR_SUFFIX;
837  return buf.str();
838  }
839 
840  /* swig produces a nicer interface if all operators are member
841  * functions.
842  */
843 #ifdef SWIG_BUILD
844 #if defined(SWIGPYTHON) && defined(SWIG)
845  %extend{
846  bool __contains__(const elt& e) const
847  { return $self->count(e) != 0; }
848 
849  iterator __iter__() const
850  { return $self->cbegin(); }
851 
852  %pythoncode{
853  def remove(self, v):
854  if not self._erase(v):
855  raise KeyError(v)
856  def discard(self, v): self._erase(v)
857  def union(self, other):
858  return self._union(other)}
859  };
860 #endif
861 
862  bool operator==(const mutable_set &other) const
863  { return inner->equals(*other.inner); }
864 
865  bool operator!=(const mutable_set &other) const
866  { return !(*this == other); }
867 #else
868 
869  template<typename _impl1>
870  friend bool
871  operator==(const mutable_set<_impl1>&, const mutable_set<_impl1>&);
873 #endif
874  };
875 
885  template<typename elt>
886  inline std::ostream &operator<<(
887  std::ostream &out,
888  const mutable_set<elt> &a )
889  {
890  a.print(out);
891  return out;
892  }
893 
894  template<typename elt>
895  class cglue< immutable_set<elt> >
896  {
897  cglue();
898  public:
899  typedef typename set_impl<elt>::ctype ctype;
900  typedef immutable_set<elt> type;
901  CS_CXX_API_CGLUE_ACCESS_MODIFIER:
902  /* Since we have no friends, no point in defining these.
903  * Instantiations can specialize cglue to make friends.
904  */
905 #if 0
906  static type wrap(const ctype &c, bool frozen)
907  { return type(c, frozen); }
908  static ctype unwrap(const type &c)
909  { return c.unwrap(); }
910 #endif
911  };
912 
922  template<typename elt>
923  inline std::ostream &operator<<(
924  std::ostream &out,
925  const immutable_set<elt> &a )
926  {
927  a.print(out);
928  return out;
929  }
930 
931  template<typename elt>
932  class cglue< mutable_set<elt> >
933  {
934  cglue();
935  public:
936  typedef typename set_impl<elt>::ctype ctype;
937  typedef mutable_set<elt> type;
938  CS_CXX_API_CGLUE_ACCESS_MODIFIER:
939  /* Since we have no friends, no point in defining these.
940  * Instantiations can specialize cglue to make friends.
941  */
942 #if 0
943  static type wrap(const ctype &c, bool frozen)
944  { return type(c, frozen); }
945  static ctype unwrap(const type &c)
946  { return c.unwrap(); }
947 #endif
948  };
949 
950  /* swig doesn't do what we want with friend functions */
951 #ifndef SWIG
952  template<typename _Elt>
959  inline bool
960  operator==(const mutable_set<_Elt>& __x,
961  const mutable_set<_Elt>& __y)
962  { return __x.inner->equals(__y.inner); }
963 
964  // Returns !(x == y).
975  template<typename _Elt>
976  inline bool
977  operator!=(const mutable_set<_Elt>& __x,
978  const mutable_set<_Elt>& __y)
979  { return !(__x == __y); }
980 #endif
981 }
982 #ifndef SWIG
983 namespace std{
985  template<typename _Elt>
986  inline void
987  swap(cs::mutable_set<_Elt>& __x, cs::mutable_set<_Elt>& __y)
988  { __x.swap(__y); }
989 }
990 #endif
991 
992 #endif /* CS_SET_HPP */
cs::mutable_set::difference
mutable_set difference(const mutable_set &b) const
Set difference.
Definition: cs_set.hpp:785
cs::immutable_set::empty
bool empty() const
Check: is the set empty?
Definition: cs_set.hpp:204
cs::mutable_set::operator=
mutable_set & operator=(mutable_set other)
Assignment operator for mutable_set.
Definition: cs_set.hpp:444
cs::immutable_set::size_type
size_t size_type
Type of set size (cardinality).
Definition: cs_set.hpp:137
Namespace for CodeSonar/CodeSurfer API.
Definition: cs_ast.hpp:33
cs::mutable_set::cbegin
iterator cbegin() const
Get an iterator whose current position is the first element in the set.
Definition: cs_set.hpp:496
cs::mutable_set::hash
cs_hash_t hash() const
Get a hash of the set.
Definition: cs_set.hpp:562
cs::mutable_set::union_p
void union_p(const mutable_set &b)
Update a set to the union of itself and another set.
Definition: cs_set.hpp:756
cs::immutable_set::operator<<
std::ostream & operator<<(std::ostream &out, const immutable_set< elt > &a)
Print a representation of a immutable_set object to the specified stream.
Definition: cs_set.hpp:923
cs::mutable_set::operator<<
std::ostream & operator<<(std::ostream &out, const mutable_set< elt > &a)
Print a representation of a mutable_set object to the specified stream.
Definition: cs_set.hpp:886
cs::mutable_set::mutable_set
mutable_set(const std::vector< mutable_set< impl > > &v)
Constructor: given a std::vector of sets, construct a set that is a multi-union of those sets...
Definition: cs_set.hpp:624
cs::mutable_set::kind
set_kind kind() const
Get the kind of a set.
Definition: cs_set.hpp:465
cs::immutable_set::const_reference
const elt & const_reference
const reference to the type of the set elements.
Definition: cs_set.hpp:128
cs::set_iterator_policy
Definition: cs_set.hpp:27
cs::immutable_set::count
size_type count(const elt &e) const
Count the number of times the specified element appears in a set.
Definition: cs_set.hpp:230
cs::mutable_set::value_type
elt value_type
The type of the set elements.
Definition: cs_set.hpp:408
cs::mutable_set::add
bool add(const elt &v)
Add an element to the set.
Definition: cs_set.hpp:662
cs::immutable_set::as_string
std::string as_string() const
Get a simple string representation of a set.
Definition: cs_set.hpp:301
cs::set_mixin
Definition: cs_set.hpp:30
cs::mutable_set::mutable_set
mutable_set()
Construct an empty set.
Definition: cs_set.hpp:583
cs::mutable_set::union_
mutable_set union_(const mutable_set &b) const
Set union.
Definition: cs_set.hpp:744
cs::mutable_set::pointer
elt * pointer
Pointer to the type of the set elements.
Definition: cs_set.hpp:411
std
Definition: cs_ast_decl.hpp:67
A single program point.
Definition: cs_point_decl.hpp:66
cs::immutable_set::pointer
elt * pointer
Pointer to the type of the set elements.
Definition: cs_set.hpp:119
cs::immutable_set::cend
iterator cend() const
Get an iterator whose current position is after the end of the set.
Definition: cs_set.hpp:196
cs::immutable_set::operator!=
bool operator!=(const immutable_set< _Impl > &__x, const immutable_set< _Impl > &__y)
Inequality operator for immutable_set.
Definition: cs_set.hpp:379
cs::immutable_set::key_type
elt key_type
The type of the set elements.
Definition: cs_set.hpp:113
cs::immutable_set::immutable_set
immutable_set(const immutable_set &other)
Copy constructor.
Definition: cs_set.hpp:151
cs::mutable_set::operator==
bool operator==(const mutable_set< _Elt > &__x, const mutable_set< _Elt > &__y)
Equality operator for mutable_set.
Definition: cs_set.hpp:960
cs::mutable_set::clear
void clear()
Remove all elements from the set (that is, make it empty).
Definition: cs_set.hpp:728
cs::immutable_set::const_iterator
iterator const_iterator
const iterator over the set contents.
Definition: cs_set.hpp:134
cs::immutable_set::reference
elt & reference
Reference to the type of the set elements.
Definition: cs_set.hpp:125
cs::mutable_set::erase
size_type erase(const elt &v)
Remove an element from the set.
Definition: cs_set.hpp:713
cs::iterator_adapter::at_end
bool at_end() const
Check: is the iterator at the end of the structure?
Definition: cs_iterator_adapter.hpp:270
cs::immutable_set::begin
iterator begin() const
Get an iterator whose current position is the first element in the set.
Definition: cs_set.hpp:170
cs::mutable_set::end
iterator end() const
Get an iterator whose current position is after the end of the set.
Definition: cs_set.hpp:487
cs::mutable_set::iterator
iterator_adapter< iterator_policy > iterator
Iterator over the set contents.
Definition: cs_set.hpp:423
cs::mutable_set::insert
std::pair< iterator, bool > insert(const elt &v)
Insert an element into the set.
Definition: cs_set.hpp:688
cs::immutable_set::operator=
immutable_set & operator=(immutable_set other)
Assignment operator for immutable_set.
Definition: cs_set.hpp:156
cs::mutable_set::count
size_type count(const elt &e) const
Count the number of times the specified element appears in a set.
Definition: cs_set.hpp:540
cs::immutable_set::cbegin
iterator cbegin() const
Get an iterator whose current position is the first element in the set.
Definition: cs_set.hpp:187
cs::immutable_set::iterator
iterator_adapter< set_iterator_policy< elt > > iterator
Iterator over the set contents.
Definition: cs_set.hpp:131
cs::immutable_set::value_type
elt value_type
The type of the set elements.
Definition: cs_set.hpp:116
cs::immutable_set::find
const_iterator find(const elt &e) const
Find element e in the set and return an iterator pointing to it if it is found.
Definition: cs_set.hpp:242
cs::immutable_set::end
iterator end() const
Get an iterator whose current position is after the end of the set.
Definition: cs_set.hpp:178
cs::mutable_set::const_pointer
const elt * const_pointer
const pointer to the type of the set elements.
Definition: cs_set.hpp:414
cs::mutable_set::begin
iterator begin() const
Get an iterator whose current position is the first element in the set.
Definition: cs_set.hpp:478
cs::mutable_set::cend
iterator cend() const
Get an iterator whose current position is after the end of the set.
Definition: cs_set.hpp:505
cs::mutable_set::size_type
size_t size_type
Type of set size (cardinality).
Definition: cs_set.hpp:429
cs::immutable_set::as_repr
std::string as_repr() const
Get a representation of a set that includes information useful for debugging.
Definition: cs_set.hpp:313
cs::immutable_set::size
size_type size() const
Get the set cardinality.
Definition: cs_set.hpp:212
cs::mutable_set::as_repr
std::string as_repr() const
Get a representation of a set object that includes information useful for debugging.
Definition: cs_set.hpp:829
cs::mutable_set::mutable_set
mutable_set(const std::vector< elt > &v)
Construct a set from a std::vector of elements.
Definition: cs_set.hpp:632
cs::mutable_set::swap
void swap(mutable_set &other)
Exchange the contents of this and other.
Definition: cs_set.hpp:527
cs::mutable_set
A set that can be modified.
Definition: cs_iterator_adapter.hpp:42
cs::mutable_set::empty
bool empty() const
Check: is the set empty?
Definition: cs_set.hpp:514
cs::mutable_set::mutable_set
mutable_set(set_kind k)
Construct an empty set of the specified kind.
Definition: cs_set.hpp:596
cs::mutable_set::size
size_type size() const
Get the set cardinality.
Definition: cs_set.hpp:522
cs::iterator_adapter
Iterator class template.
Definition: cs_iterator_adapter.hpp:65
cs::set_impl
Definition: cs_set.hpp:26
Enumeration class: the kind of a set.
Definition: cs_set.hpp:36
cs::immutable_set::swap
void swap(immutable_set &other)
Exchange the contents of this and other.
Definition: cs_set.hpp:217
cs::mutable_set::const_reference
const elt & const_reference
const reference to the type of the set elements.
Definition: cs_set.hpp:420
cs::mutable_set::const_iterator
iterator const_iterator
const iterator over the set contents.
Definition: cs_set.hpp:426
cs::mutable_set::key_type
elt key_type
The type of the set elements.
Definition: cs_set.hpp:405
cs::mutable_set::to_vector
std::vector< elt > to_vector() const
Get a std::vector of all the elements in the set.
Definition: cs_set.hpp:573
cs::immutable_set::operator==
bool operator==(const immutable_set< _Impl > &__x, const immutable_set< _Impl > &__y)
Equality operator for immutable_set.
Definition: cs_set.hpp:364
cs::mutable_set::operator!=
bool operator!=(const mutable_set< _Elt > &__x, const mutable_set< _Elt > &__y)
Inequality operator for mutable_set.
Definition: cs_set.hpp:977
cs::mutable_set::find
const_iterator find(const elt &e) const
Find element e in the set and return an iterator pointing to it if it is found.
Definition: cs_set.hpp:551
cs::mutable_set::as_string
std::string as_string() const
Get a simple string representation of a set object.
Definition: cs_set.hpp:819
cs::immutable_set::hash
cs_hash_t hash() const
Get a hash of the set.
Definition: cs_set.hpp:253
cs::immutable_set
A set that cannot be modified.
Definition: cs_iterator_adapter.hpp:43
cs::immutable_set::to_vector
std::vector< elt > to_vector() const
Get a std::vector of all the elements in the set.
Definition: cs_set.hpp:259
cs::mutable_set::mutable_set
mutable_set(const mutable_set &other)
Copy constructor.
Definition: cs_set.hpp:439
cs::mutable_set::intersect
mutable_set intersect(const mutable_set &b) const
Set intersection.
Definition: cs_set.hpp:772
cs::mutable_set::reference
elt & reference
Reference to the type of the set elements.
Definition: cs_set.hpp:417
cs::immutable_set::const_pointer
const elt * const_pointer
const pointer to the type of the set elements.
Definition: cs_set.hpp:122