Commit 19b19056 authored by Tirso V. Rodeiro's avatar Tirso V. Rodeiro
Browse files

README

parent e5457034
# cds-template
Template for creating a Compact Data Structure project using SDSL library.
\ No newline at end of file
Template for creating a Compact Data Structure project using SDSL library.
####A little example
This code shows how we can create a simple data structure (table_bitmap) that receives as an input an integer pair vector and recognizes each pair as (index, data). In order to store this information, this code uses a bit_vector and an int_vector respectively.
The main function loads 5 random pairs into this data structure and outputs what positions were filled and its content. As it can be seen in the constructor, the length of the bit_vector will be the maximum index included in the input and the length of the int_vector will be the number of pairs received.
Table_bitmap.hpp includes also some basic concepts that you will use in all your CDS projects as type definitions, SDSL library usage or class functions management.
####Installing the example
- git clone
- ./cds-template/compile.sh (if needed, use chmod +x path/compile.sh)
- ./cds-template/build/template_executable
\ No newline at end of file
File mode changed from 100644 to 100755
......@@ -94,14 +94,14 @@ namespace cds {
* Constructor
* Container can be any class.
* Depending on the implementation it requires some methods.
* In this case we need that the container supports iterators, size, and each element a first and second atrribute.
* In this case we need that the container supports iterators, size, and each element a first and second attribute.
*/
template <class Container>
table_bitmap(const Container &input){
//1.Computing the maximum key value
//We need iterators (begin, end) because we are using a for
value_type max_key = 0;
//Const: no modification; &var: the value is obtained by reference (no copy)
//Const: no modification; &var: the value is obtained by reference (not a copy)
for(const auto &element : input){
//We need a first and second because we are assuming the container contains pairs
if(element.first > max_key) max_key = element.first;
......@@ -200,7 +200,7 @@ namespace cds {
//Serialize to a stream
size_type serialize(std::ostream& out, sdsl::structure_tree_node* v=nullptr, std::string name="")const
{
//Create a node and store the different elements of our structrue in that node
//Create a node and store the different elements of our structure in that node
sdsl::structure_tree_node* child = sdsl::structure_tree::add_child(v, name, sdsl::util::class_name(*this));
size_type written_bytes = 0;
written_bytes += m_bitmap.serialize(out, child, "bitmap");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment