LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
lal::linarr::chunk_sequence Class Reference

Chunk sequence of a syntactic dependency tree. More...

#include <chunk_sequence.hpp>

Public Types

typedef std::vector< chunk >::const_iterator const_iterator
 Useful typedef for constant iterators.
 
typedef std::vector< chunk >::iterator iterator
 Useful typedef for non-constant iterators.
 

Public Member Functions

void init (const std::size_t n) noexcept
 Initializes this chunk sequence.
 
const chunkoperator[] (const std::size_t i) const noexcept
 The i-th chunk.
 
chunkoperator[] (const std::size_t i) noexcept
 The i-th chunk.
 
void push_chunk () noexcept
 Adds a new chunk to the collection.
 
void push_chunk (const node u) noexcept
 Adds a new chunk to the collection.
 
std::size_t size () const noexcept
 Returns the number of chunks.
 
std::size_t get_chunk_index (const node u) const noexcept
 Returns the chunk index of node u.
 
const_iterator begin () const noexcept
 A pointer to the beginning of the chunk sequence.
 
iterator begin () noexcept
 A pointer to the beginning of the chunk sequence.
 
const_iterator end () const noexcept
 A pointer to the ending of the chunk sequence.
 
iterator end () noexcept
 A pointer to the ending of the chunk sequence.
 
const std::vector< chunk > & get_chunks () const noexcept
 The sequence of chunks.
 

Private Attributes

std::vector< chunkm_chunks
 The sequence of chunks.
 
detail::array< std::size_t > m_from_node_to_chunk
 Index of every.
 

Detailed Description

Chunk sequence of a syntactic dependency tree.

This can be seen as the ordered sequence of chunks obtained from applying a chunking algorithm. The sequence is ordered because the first chunk (at index 0) is the leftmost chunk in the ordering of the nodes. For instance, we may have the following tree (in the head vector format – see Head vector),

2 5 2 5 0 9 9 9 10 5

The chunks obtained could be (there are other ways to obtain chunks) the follownig

|-------|-----|----------|---|
| 2 5 2 | 5 0 | 9 9 9 10 | 5 |
|-------|-----|----------|---|
    0      1       2       3

and so the first chunk has index 0, the second chunk index 1, and so on. Use

// call a chunking algorithm
const std::vector<chunk> chunks = s.get_chunks();
const chunk& c0 = chunks[0];
const chunk& c1 = chunks[1];
// ...
Chunk sequence of a syntactic dependency tree.
Definition chunk_sequence.hpp:107
const std::vector< chunk > & get_chunks() const noexcept
The sequence of chunks.
Definition chunk_sequence.hpp:213
Definition of a chunk.
Definition chunk.hpp:64

Nodes can be queried for their chunk index with method get_chunk_index. Since in the tree example the nodes are distributed from left to right, the chunk indices are the following (left column: nodes, right column: chunk index).

0: 0
1: 0
2: 0
3: 1
4: 1
5: 2
6: 2
7: 2
8: 2
9: 3

Member Function Documentation

◆ get_chunks()

const std::vector< chunk > & lal::linarr::chunk_sequence::get_chunks ( ) const
inlinenodiscardnoexcept

The sequence of chunks.

See member m_chunks.

Returns
A constant reference to the sequence of chunks.

◆ init()

void lal::linarr::chunk_sequence::init ( const std::size_t n)
inlinenoexcept

Initializes this chunk sequence.

Parameters
nSize to initialize the sequence with, the number of nodes of the tree to be chunked.

◆ operator[]() [1/2]

const chunk & lal::linarr::chunk_sequence::operator[] ( const std::size_t i) const
inlinenodiscardnoexcept

The i-th chunk.

Parameters
iChunk index.
Returns
A constant reference to the i-th chunk.

◆ operator[]() [2/2]

chunk & lal::linarr::chunk_sequence::operator[] ( const std::size_t i)
inlinenodiscardnoexcept

The i-th chunk.

Parameters
iChunk index.
Returns
A non-constant reference to the i-th chunk.

◆ push_chunk() [1/2]

void lal::linarr::chunk_sequence::push_chunk ( )
inlinenoexcept

Adds a new chunk to the collection.

Postcondition
The new chunk does not have a parent.

◆ push_chunk() [2/2]

void lal::linarr::chunk_sequence::push_chunk ( const node u)
inlinenoexcept

Adds a new chunk to the collection.

Parameters
uNode to be added into the new chunk.
Postcondition
The new chunk does not have a parent.

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