Skip to content

Commit

Permalink
Make interval trees containers
Browse files Browse the repository at this point in the history
  • Loading branch information
wrwilliams committed Sep 7, 2016
1 parent 58d4c19 commit 738a1cd
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion common/h/IBSTree.h
Expand Up @@ -142,6 +142,7 @@ class IBSNode {
~IBSNode() { }

interval_type value() const { return val_; };
interval_type operator*() const { return value; }

private:
/* The endpoint of an interval range */
Expand All @@ -161,7 +162,15 @@ class IBSNode {

template<class ITYPE = interval<> >
class IBSTree {
public:
typedef typename ITYPE::type interval_type;
typedef IBSNode<ITYPE>* iterator;
typedef const IBSNode<ITYPE>* const_iterator;
typedef ITYPE value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t difference_type;
typedef size_t size_type;

IBSNode<ITYPE> *nil;

Expand Down Expand Up @@ -235,7 +244,18 @@ class IBSTree {
delete nil;
}

int size() const { return treeSize; }
size_type size() const { return treeSize; }
const_iterator begin() const {
iterator b = root;
while(root->left) b = root->left;
return b;
}
const_iterator end() const {
iterator e = root;
while(root->right) e = root->right;
return e;

}
int CountMarks() const;

bool empty() const { return (root == nil); }
Expand Down

0 comments on commit 738a1cd

Please sign in to comment.