#ifndef _NESTED_H #define _NESTED_H #include #include #include #include "region.h" namespace cis { typedef std::map BY_START; typedef std::map BY_END; class dna_t; class region_tree { public: region_tree(region const* r); ~region_tree(); region const* interval; BY_START * children; //will be the owner of the subtrees /* BY_END * children_by_end; */ void insert_rec(region const*); //creates a new node and inserts it appropriately into the tree structure... void insert(region const*); //creates a new node and inserts it appropriately into the tree structure... private: region_tree(region_tree const&); region_tree & operator=(region_tree const&); region_tree(region_tree &); region_tree & operator=(region_tree &); region_tree(); }; typedef std::map TREE_MAP; REGIONS_MULTI IntervalOverlap(region_tree const&, region const&); std::pair RangeQuery(BY_START const*, region const&); std::pair NonOverlappingNeighbors(BY_START const*, BY_END const*, region const& q); region_tree * BuildTree(REGIONS_MULTI const&); std::set > GetAllNeighbors(REGIONS_MULTI const&, region_tree const&, int); //a safe and efficient test of less //template bool less_iterator(BY_START::iterator & a, BY_START::iterator & b, BY_START::iterator & end); void print_tree(region_tree const* node, int indent_level); /* int node_index (node const& n){ return n.interval.start; } struct less_node_start { bool operator()(node const& a, node const& b){ return node_index(a) < node_index(b); } }; typedef std::set NSET; //what should be the interface for the nested class? //besides insert and erase, size, empty, what other things? //we want to be able to do a range query. class nested : public NSET {}; //ordering consistent with the forward depth first search traversal //of a nested containment tree structure struct forward_depth_first { bool operator()(node const& an, node const& bn){ INTERVAL &a = an.interval; INTERVAL &b = bn.interval; return a.start < b.start || (a.start == b.start && (a.end > b.end || (a.end == b.end && (a.id < b.id)))); } }; //ordering consistent with the depth-first traversal of the same //tree, but struct reverse_depth_first { bool operator()(node const& an, node const& bn){ INTERVAL &a = an.interval; INTERVAL &b = bn.interval; return a.end < b.end || (a.end == b.end && (a.start < b.start || (a.start == b.start && (a.id > b.id)))); } }; */ } // namespace cis #endif //_NESTED_H