Space-efficient geometric algorithms and data structures

By Ilya Katz and Hervé Brönnimann    

inplaceds::block_tree_heap< SequenceIterator, Geometry, _Compare, _Compare_PQ, _Alloc > Class Template Reference

#include <block_tree_heap.hpp>

Collaboration diagram for inplaceds::block_tree_heap< SequenceIterator, Geometry, _Compare, _Compare_PQ, _Alloc >:

Collaboration graph
[legend]

Detailed Description

template<class SequenceIterator, class Geometry, class _Compare = std::less<typename SequenceIterator::value_type>, class _Compare_PQ = std::less<typename SequenceIterator::value_type>, class _Alloc = std::allocator<typename SequenceIterator::value_type>>
class inplaceds::block_tree_heap< SequenceIterator, Geometry, _Compare, _Compare_PQ, _Alloc >

A standard container made up of unique keys, which can be retrieved in logarithmic time.

Parameters:
Key Type of key objects.
Compare Comparison function object type for priority queue, defaults to less<Key>.
Compare_PQ Comparison function object type for binary search tree, defaults to less<Key>.
Alloc Allocator type, defaults to allocator<Key>.
my_tree_heap supports iterators. Keep these two things in mind if using iterators: There are some important prerequisites

Todo:
TODO: clear()

TODO: copy contrucrs

TODO: change documentation

TODO: top() cannot return an interator beacuse top() is not necesarily in the BST - should return pointer

TODO: when doing BST swap, is it enouhg to just swap lines and do adjust_PQ

TODO: why is iterator not inherited

Definition at line 146 of file block_tree_heap.hpp.

Constructors

 block_tree_heap (SequenceIterator f, SequenceIterator l, int b=1)
 Builds a my_tree_heap from a range.
template<class RandomAccessIterator>
 block_tree_heap (RandomAccessIterator first, RandomAccessIterator last, const _Compare &__comp, const _Compare_PQ &__comp_pq, const allocator_type &__a=allocator_type())
 Builds a my_tree_heap from a range.
 ~block_tree_heap ()
 block_tree_heap (const block_tree_heap< _Key, Geometry, _Compare, _Compare_PQ, _Alloc > &__x)

Public Types

typedef _Space_TH_Iterator<
DataNode
iterator
typedef std::iterator_traits<
SequenceIterator >::difference_type 
block_size_type
Iterator-related typedefs
typedef _Alloc::pointer pointer
typedef _Alloc::const_pointer const_pointer
typedef _Alloc::reference reference
typedef _Alloc::const_reference const_reference
typedef block::_Rb_tree< SequenceIterator,
DataNode, _M_KeyOfValue,
_M_key_comp,_M_key_comp_pq,
_Alloc > 
_Rep_type
typedef DataNode::event_type event_type
typedef DataNode::priority_type priority_type
typedef _Rep_type::const_iterator const_iterator
typedef _Rep_type::const_reverse_iterator reverse_iterator
typedef _Rep_type::const_reverse_iterator const_reverse_iterator
typedef _Rep_type::size_type size_type
typedef _Rep_type::difference_type difference_type
typedef _Rep_type::allocator_type allocator_type

Public Member Functions

tree_heap functions
void print ()
 Prints pre-order traversal of PQ and BST.
SequenceIterator no_full_block ()
const iterator insert (SequenceIterator new_line)
void insert_into_gap (tree_iterator it, SequenceIterator new_line)
void update_left_most_pointer (tree_iterator it, int new_size)
value_type move_blocks (SequenceIterator first, SequenceIterator last)
 Move all elements starting at in range [first,last] left by one element and place the first element in unprocessed segments section into first.
void update_top_pq (tree_iterator it)
DataNodecreate_node (SequenceIterator l)
SequenceIterator get_gap (tree_iterator block)
SequenceIterator get_gap (const DataNode &block)
 IF THIS IS CHNAGED ALSO NEED TO CHNAGE KEYOFVALUE.
void set_gap (tree_iterator block, SequenceIterator new_gap, block_size_type gap_size)
void set_gap (tree_iterator block, SequenceIterator new_gap)
SequenceIterator get_leftmost_gap (block_size_type size)
void swap_gaps (SequenceIterator b1, SequenceIterator b2, block_size_type size)
 Swaps two blocks of sizes size.
block_size_type max_gap_size ()
 Returns the size of the maximum gap.
void update_block_after_insert (tree_iterator &block, SequenceIterator new_el)
SequenceIterator get_top_pq (tree_iterator it)
void set_top_pq (tree_iterator it, SequenceIterator new_top)
event_type get_event (iterator block)
void pop ()
 Removes an element that is located at the top of the queue from the queue and from BST.
iterator top () const
 Returns pointer to the top of the priority queue.
priority_type get_priority (iterator block)
void segment_intersection_event (iterator it)
 Performs intersection event operations on a line segment.
bool empty ()
Generic functions
key_compare key_comp () const
 Returns the comparison object with which the my_tree_heap BST was constructed.
key_compare_pq key_comp_pq () const
 Returns the comparison object with which the my_tree_heap PQ was constructed.
allocator_type get_allocator () const
 Returns the allocator object with which the my_tree_heap was constructed.
const_iterator begin () const
 Returns a read/write iterator that points to the first element in the my_tree_heap. Iteration is done in ascending order according to the keys.
iterator begin ()
const_iterator end () const
 Returns a read/write iterator that points one past the last element in the my_tree_heap. Iteration is done in ascending order according to the keys.
iterator end ()
bool empty () const
size_type size () const
 Returns the size of the my_tree_heap.
void clear ()
 Erases all elements in a my_tree_heap.

Data Fields

_Rep_type _M_t
block_size_type block_size
SequenceIterator _M_last_in_th
 specifies the element which is last element in tree/heap
tree_iterator _M_last_gap
tree_iteratorleft_most_gap
 Array that holds the pointer to the node that points to the leftmost gap of size x.
block_size_typegaps_offsets
 Array that hold offset to gaps.
_Compare _comp
 BST coparison object.
_Compare_PQ _comp_pq
 PQ comparison object.
Valid range
Specifies valid range for this tree/heap. This includes processed , partial and full tree/heap, and uprocessed blocks

SequenceIterator _M_first
SequenceIterator _M_last

Private Types

typedef _Rep_type::iterator tree_iterator
Public typedefs
typedef SequenceIterator::value_type _Key
typedef _Key key_type
typedef _Key value_type
typedef _Compare key_compare
typedef _Compare_PQ key_compare_pq
typedef key_typekey_ptr
typedef Geometry::point_type priority_type

Private Member Functions

iterator successor (iterator block)
SequenceIterator successor (tree_iterator node, SequenceIterator line)
 Returns the successor of the line in the node or in the next one if line is the last element in this node.
iterator predecessor (iterator block)
void swap_lines (iterator a, iterator b)
 Swaps two line segments in the BST.
void adjust_PQ (iterator it)
 If a node's priority was chnaged, the PQ needs to be adjusted.
void erase (iterator __position)
 Erases an element from a tree_heap (both from PQ and BST).

Data Structures

struct  _M_key_comp
 This is the functor that is passed to the rb_tree for comparisons of tree nodes. More...
struct  _M_key_comp_pq
 This is the functor that is passed to the rb_tree for comparisons of tree nodes. More...
struct  _M_KeyOfValue
class  _Space_TH_Iterator
 Iterator class for the block_tree_heap. More...
struct  DataNode
 Defines nodes in the underlying rb-tree. DataNode is a structure that encapsulates information regarding a line segment and its event. Specifically it contains a SequenceIterator to the first active line segment of a block and its event and intersection line (if applicable). More...


The documentation for this class was generated from the following file:

Code Documentation generated Using Doxygen

Copyright © Ilya Katz and Hervé Brönnimann, 2005, 2006.