|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Builds an index of nodes for fast search and retrieval. More...
#include <tpl_indexNode.H>
Public Member Functions | |
| GT_Node * | insert (GT_Node *p) |
| Inserts the node p into the index. | |
| GT_Node * | insert_in_graph (const GT_Node_Type &info) |
| Creates a new node with generic content info, inserts it into the graph, and then into the index. | |
| GT_Node * | insert_in_graph (GT_Node_Type &&info) |
| GT_Node * | search (GT_Node *p) |
| Searches for a node based on the content of p. | |
| GT_Node * | search (const GT_Node_Type &info) |
| Searches for a node based on the info. | |
| void | remove (GT_Node *p) |
| Removes the node at address p from the index. | |
| void | remove_from_graph (GT_Node *p) |
| Removes the node p from the graph and the index. | |
| void | clear_index () |
| Clears the index; all nodes are removed from it. | |
| void | build_index () |
| Inserts all nodes from the graph into the index. | |
| void | clear_graph () |
| Removes all nodes from the graph and the index. | |
| IndexNode (GT &__g, SN __sn=SN()) | |
| Creates an index from the nodes inserted in the graph. | |
| size_t | size () const |
| Returns the number of items contained in the index. | |
Private Types | |
| typedef GT::Node | GT_Node |
| typedef GT::Node_Type | GT_Node_Type |
Private Member Functions | |
| void | init () |
Private Attributes | |
| DynSetTree< GT_Node *, Tree, Compare > | index |
| GT & | g |
| SN | sn |
Builds an index of nodes for fast search and retrieval.
IndexNode indexes the nodes of a graph according to a user-defined key.
| GT | The graph type, based on List_Graph. |
| Compare | The comparison class for the indexing key. The contract for this class is to implement the () operator as follows: template <class GT>
struct Dft_Node_Cmp
{
bool
{
// access nodes and compare based on the desired field
}
};
|
| SN | The filter class for the node iterator, if one is constructed. |
| Tree | The binary search tree type used internally for indexing keys. By default, Treaps are used. |
Definition at line 128 of file tpl_indexNode.H.
|
private |
Definition at line 130 of file tpl_indexNode.H.
|
private |
Definition at line 131 of file tpl_indexNode.H.
|
inline |
Creates an index from the nodes inserted in the graph.
| __g | The graph. |
| __sn | A node filter object. |
| std::bad_alloc | if there is not enough memory. |
Definition at line 285 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::init().
|
inline |
Inserts all nodes from the graph into the index.
Definition at line 252 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::g, Aleph::IndexNode< GT, Compare, Tree, SN >::insert(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::IndexNode< GT, Compare, Tree, SN >::search(), and Aleph::IndexNode< GT, Compare, Tree, SN >::sn.
|
inline |
Removes all nodes from the graph and the index.
Definition at line 263 of file tpl_indexNode.H.
References Aleph::clear_graph(), Aleph::IndexNode< GT, Compare, Tree, SN >::clear_index(), and Aleph::IndexNode< GT, Compare, Tree, SN >::g.
|
inline |
Clears the index; all nodes are removed from it.
Definition at line 246 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::index.
Referenced by Aleph::IndexNode< GT, Compare, Tree, SN >::clear_graph().
|
inlineprivate |
Definition at line 271 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::g, Aleph::IndexNode< GT, Compare, Tree, SN >::insert(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), and Aleph::IndexNode< GT, Compare, Tree, SN >::sn.
Referenced by Aleph::IndexNode< GT, Compare, Tree, SN >::IndexNode().
|
inline |
Inserts the node p into the index.
| p | Pointer to the node to be stored in the index. |
| std::bad_alloc | if there is not enough memory. |
Definition at line 146 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::index.
Referenced by Aleph::IndexNode< GT, Compare, Tree, SN >::build_index(), Aleph::IndexNode< GT, Compare, Tree, SN >::init(), Aleph::IndexNode< GT, Compare, Tree, SN >::insert_in_graph(), and Aleph::IndexNode< GT, Compare, Tree, SN >::insert_in_graph().
|
inline |
Creates a new node with generic content info, inserts it into the graph, and then into the index.
| info | Content associated with the new node. |
| std::bad_alloc | if there is not enough memory. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 159 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::g, Aleph::IndexNode< GT, Compare, Tree, SN >::insert(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), Aleph::maps(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::remove_node().
Referenced by main().
|
inline |
Removes the node at address p from the index.
Definition at line 227 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::index.
|
inline |
Removes the node p from the graph and the index.
| p | Pointer to the node to be removed. |
| std::domain_error | if the node is not in the index (which likely means it's not in the graph either). |
Definition at line 238 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::g, Aleph::IndexNode< GT, Compare, Tree, SN >::index, and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::remove_node().
|
inline |
Searches for a node based on the info.
Note that the search criterion is determined by the Compare template parameter class.
| info | The information to search for. |
Definition at line 220 of file tpl_indexNode.H.
References Aleph::maps(), and Aleph::IndexNode< GT, Compare, Tree, SN >::search().
|
inline |
Searches for a node based on the content of p.
Note that the search criterion is determined by the Compare template parameter class.
| p | The node whose information is to be searched for. |
Definition at line 201 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::index, and Aleph::maps().
Referenced by Aleph::IndexNode< GT, Compare, Tree, SN >::build_index(), and Aleph::IndexNode< GT, Compare, Tree, SN >::search().
|
inline |
Returns the number of items contained in the index.
Definition at line 291 of file tpl_indexNode.H.
References Aleph::IndexNode< GT, Compare, Tree, SN >::index.
|
private |
Definition at line 135 of file tpl_indexNode.H.
Referenced by Aleph::IndexNode< GT, Compare, Tree, SN >::build_index(), Aleph::IndexNode< GT, Compare, Tree, SN >::clear_graph(), Aleph::IndexNode< GT, Compare, Tree, SN >::init(), Aleph::IndexNode< GT, Compare, Tree, SN >::insert_in_graph(), Aleph::IndexNode< GT, Compare, Tree, SN >::insert_in_graph(), and Aleph::IndexNode< GT, Compare, Tree, SN >::remove_from_graph().
|
private |
Definition at line 133 of file tpl_indexNode.H.
Referenced by Aleph::IndexNode< GT, Compare, Tree, SN >::clear_index(), Aleph::IndexNode< GT, Compare, Tree, SN >::insert(), Aleph::IndexNode< GT, Compare, Tree, SN >::remove(), Aleph::IndexNode< GT, Compare, Tree, SN >::remove_from_graph(), Aleph::IndexNode< GT, Compare, Tree, SN >::search(), and Aleph::IndexNode< GT, Compare, Tree, SN >::size().
|
private |
Definition at line 136 of file tpl_indexNode.H.
Referenced by Aleph::IndexNode< GT, Compare, Tree, SN >::build_index(), and Aleph::IndexNode< GT, Compare, Tree, SN >::init().