46 using Entry =
typename Configuration::Entry;
50 _conf( configuration )
97 void print( std::ostream& out = std::cout )
const;
115 using Node =
typename Tree::Node;
158 return lhs.
pos == rhs.
pos;
163 return !(lhs == rhs);
188 return _tree.getMemoryUse();
194 return std::string(
"heap(" ) + (C::fastIndex ?
"fi" :
"si") + (C::supportDeduplicationWhileOrdering ?
" dedup" :
"") +
')';
201 _tree.pushBack( entry );
202 moveValueUp( _tree.lastLeaf(), entry );
209 for( ; begin != end; ++begin )
216 moveValueUp( moveHoleDown(
Node() ), newEntry );
224 Entry movedValue = _tree[_tree.lastLeaf()];
227 moveValueUp( moveHoleDown(
Node() ), movedValue );
236 out << get_name() << _tree.size() <<
": {" << _tree <<
"}\n";
242 const Node firstWithout2Children = _tree.lastLeaf().next().parent();
243 while( hole < firstWithout2Children )
246 Node child = hole.left();
247 Node sibling = child.next();
248 if( _conf.cmpLessThan( _conf.compare( _tree[child], _tree[sibling] )))
250 _tree[hole] = _tree[child];
254 if( hole == firstWithout2Children && _tree.lastLeaf().isLeft() )
256 Node child = hole.left();
257 _tree[hole] = _tree[child];
290 while( !pos.isRoot() )
292 const Node up = pos.parent();
294 if( _conf.cmpLessThan( cmp ))
296 _tree[pos] = _tree[up];
299 else if( C::supportDeduplicationWhileOrdering && _conf.cmpEqual( cmp ))
332 assert( _tree.isValid() );
334 for(
Node i =
Node().next(); i <= _tree.lastLeaf(); ++i )
346 assert( !_conf.cmpLessThan( _conf.compare( _tree[i.parent()], _tree[i] )));
This file has been extracted from mathic.
carl is the main namespace for the library.
This class represents a tree.
std::vector< Entry > getCopy() const
void popPosition(c_iterator pos)
size_t getMemoryUse() const
void print(std::ostream &out=std::cout) const
void push(const Entry *begin, const Entry *end)
void moveValueUp(Node pos, Entry value)
std::vector< Entry > getCopy() const
std::string get_name() const
Node moveHoleDown(Node hole)
void moveValueDown(Node pos, Entry value)
Heap(const Configuration &configuration)
typename Configuration::Entry Entry
Configuration & getConfiguration()
void decreaseTop(Entry newEntry)
const Configuration & getConfiguration() const
void decreasePos(Entry newEntry, c_iterator pos)
friend bool operator!=(c_iterator lhs, c_iterator rhs)
const Node & getNode() const
friend bool operator==(c_iterator lhs, c_iterator rhs)
c_iterator(const Tree &tree)