21 #include "SheafSystem/interval_set.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/deep_size.h" 24 #include "SheafSystem/interval_set_iterator.h" 61 ensure(*
this == xother);
94 result = (_interval_map == xother._interval_map);
111 put_interval(xbegin, xend,
true);
116 ensure(interval_is_full(xbegin, xend));
131 put_interval(xmbr, xmbr,
true);
136 ensure(contains_member(xmbr));
151 put_interval(xbegin, xend,
false);
156 ensure(interval_is_empty(xbegin, xend));
171 put_interval(xmbr, xmbr,
false);
176 ensure(!contains_member(xmbr));
193 map_type::const_iterator litr = _interval_map.lower_bound(xmbr);
195 result = (litr != _interval_map.end());
197 result = litr->second;
218 map_type::const_iterator litr = _interval_map.lower_bound(xbegin);
222 while((litr != _interval_map.end()) && (lbegin <= xend))
235 result += (xend - lbegin) + 1;
242 result += (lend - lbegin) + 1;
267 map_type::const_iterator litr = _interval_map.lower_bound(xbegin);
270 (litr == _interval_map.end()) ||
271 (!litr->second && (litr->first >= xend));
290 map_type::const_iterator litr = _interval_map.lower_bound(xbegin);
293 (litr != _interval_map.end()) &&
294 litr->second && (litr->first >= xend);
319 result = _interval_map.begin()->first+1;
324 ensure(is_empty() ? !
is_valid(result) :
true);
350 result = litr->first;
355 ensure(is_empty() ? !
is_valid(result) :
true);
370 _interval_map.clear();
392 result = _interval_map.empty();
396 ensure(is_basic_query);
427 sheaf::interval_set::
490 map_type::iterator litr = _interval_map.find(xbegin-1);
491 if(litr != _interval_map.end())
495 bool lold_begin = litr->second;
496 if(lold_begin == xvalue)
501 _interval_map.erase(litr);
514 bool lold_begin = contains_member(xbegin);
515 if(lold_begin == xvalue)
524 _interval_map[xbegin-1] = lold_begin;
530 bool lold_end = contains_member(xend);
532 litr = _interval_map.find(xend);
533 if(litr != _interval_map.end())
537 if(lold_end == xvalue)
547 _interval_map.erase(litr);
554 if(lold_end == xvalue)
564 _interval_map[xend] = xvalue;
570 litr = _interval_map.lower_bound(xbegin);
571 while(litr != _interval_map.end() && litr->first < xend)
573 _interval_map.erase(litr);
574 litr = _interval_map.lower_bound(xbegin);
597 return _interval_map;
606 require(!is_empty());
610 bool result = _interval_map.begin()->second;
625 require(!is_empty());
629 bool result = (--_interval_map.end())->second;
661 bool result =
dynamic_cast<const interval_set*
>(other) != 0;
696 _interval_map = xother._interval_map;
700 ensure(*
this == xother);
713 if(invariant_check())
717 invariance(any::invariant());
721 disable_invariant_check();
725 invariance(is_empty() || !first_map_entry());
727 itr != interval_map().end(), ++itr; ++i,
728 itr->second == (i%2 == 1));
729 invariance(is_empty() || last_map_entry());
733 enable_invariant_check();
757 xos << endl <<
"begin: " << xset.
begin()
758 << endl <<
"end: " << xset.
end() << endl;
760 xos << endl <<
"members:" << endl;
771 xos << endl << endl <<
"non-members:" << endl;
800 result = xinclude_shallow ?
sizeof(xset) : 0;
806 result += deep_size<pod_type, bool, map_policy_type>(xset._interval_map,
false);
An iterator over the integers in an interval_set.
bool is_empty() const
True, if this set is empty.
bool contains_member(pod_type xmbr) const
True, if the integer xmbr is in this set.
const map_type & interval_map() const
Map that defines the intervals of this set.
Set of integers optimized for when the integers are concentrated in closed intervals.
bool last_map_entry() const
Value of the last map entry.
pod_index_type pod_type
The "plain old data" index type for this set.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
bool interval_is_empty(pod_type xbegin, pod_type xend) const
True, if there are no members in this set for the interval [xbegin, xend].
std::map< pod_type, bool > map_type
The type of the interval map.
Abstract base class with useful features for all objects.
bool operator==(const interval_set &xother) const
True if this is equivalent to xother.
Do not call deep_size on either the key or value.
pod_type begin() const
The first member in this set.
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
bool interval_is_full(pod_type xbegin, pod_type xend) const
True, if there is a continuous interval of members [xbegin, xend] in this set.
interval_set()
Default constructor.
pod_type item() const
The current integer of the iteration.
virtual bool invariant() const
Class invariant.
void next()
Makes item() the next integer in the iteration.
size_type member_ct(pod_type xbegin, pod_type xend) const
The number of members in the interval [xbegin, xend].
pod_type end() const
The last member in this set.
interval_set_iterator * iterator(bool xis_full_iterator) const
Iterator for this set. If xis_full_iterator, iterate over the members in the set. Otherwise...
void insert_interval(pod_type xbegin, pod_type xend)
Insert an interval of members [xbegin, xend] into this set.
virtual interval_set * clone() const
Virtual constructor, makes a new instance of the same type as this.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
~interval_set()
Destructor.
interval_set & operator=(const interval_set &xother)
Assignment operator.
void clear()
Clear this set.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
void remove_interval(pod_type xbegin, pod_type xend)
Remove an interval of members [xbegin, xend] from this set.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
bool is_done() const
True if iteration is finished.
void insert_member(pod_type xmbr)
Insert xmbr into this set.
map_type::const_iterator map_iterator_type
The type of the interval map iterator.
void remove_member(pod_type xmbr)
Remove xmbr from this set.
bool first_map_entry() const
Value of the first map entry.