ModErn Text Analysis
META Enumerates Textual Applications
Classes | Typedefs | Functions | Variables
meta::util Namespace Reference

Shared resources and utilities. More...

Classes

struct  aligned_allocator
 
class  array_view
 A non-owning reference to an array (or part of one). More...
 
class  bad_optional_access
 Exception thrown when trying to obtain the value of a non-engaged optional. More...
 
class  basic_range
 Implements a range that spans a loop's extension and termination conditions, most useful for iterating over a range of numbers with a range-based for loop. More...
 
class  basic_string_view
 A non-owning reference to a string. More...
 
class  chunk_iterator
 A simple implementation of the ChunkIterator concept that reads Records from a binary file using io::packed::read. More...
 
class  comparable
 A CRTP base class that allows for inheritance of all comparator operators given that the derived class defines an operator<(). More...
 
class  dense_matrix
 Simple wrapper class for representing a dense matrix laid out in row-major order (that is, its internal representation is a linear array of the rows). More...
 
class  destructive_chunk_iterator
 A simple implementation of the ChunkIterator concept that reads Records from a binary file using io::packed::read and deletes the underlying file when it reaches EOF. More...
 
class  disk_vector
 disk_vector represents a large constant-size vector that does not necessarily fit in memory. More...
 
class  disk_vector_exception
 Basic exception for disk_vector. More...
 
class  factory
 Generic factory that can be subclassed to create factories for specific types. More...
 
class  factory_exception
 Simple exception for factories. More...
 
class  fixed_heap
 Keeps a constant number of high-priority elements. More...
 
struct  identifier
 Base template that denotes an identifier. More...
 
class  invertible_map
 This data structure indexes by keys as well as values, allowing constant amortized lookup time by key or value. More...
 
class  invertible_map_exception
 Basic exception for invertible_map interactions. More...
 
struct  is_numeric
 Type trait for numeric. More...
 
class  multilevel_clonable
 Template class to facilitate polymorphic cloning. More...
 
struct  nullopt_t
 A dummy type for representing a disengaged option<T>. More...
 
struct  numeric
 Empty helper class to denote that something is numeric. More...
 
struct  numerical_identifier
 A CRTP template base that adds numeric functionality to the identifier type. More...
 
class  optional
 A class for representing optional values. More...
 
struct  optional_dummy_t
 A dummy type for optional storage. More...
 
union  optional_storage
 A storage class for the optional<T> class. More...
 
class  persistent_stack
 
class  persistent_stack_exception
 
class  pimpl
 Class to assist in simple pointer-to-implementation classes. More...
 
class  sparse_vector
 Represents a sparse vector, indexed by type Index and storing values of type Value. More...
 
class  transform_iterator
 Wrapper around an Iterator that, when dereferenced, returns f(*it) where it is the wrapped Iterator and f is a UnaryFunction. More...
 
struct  trivial_init_t
 A tag for trivial initialization of optional storage. More...
 

Typedefs

template<class T , std::size_t Alignment = 64>
using aligned_vector = std::vector< T, aligned_allocator< T, Alignment >>
 
template<class Base , class Derived >
using clonable = multilevel_clonable< Base, Base, Derived >
 Template alias to facilitate polymorphic cloning. More...
 
using string_view = basic_string_view< char >
 
using u16string_view = basic_string_view< char16_t >
 
using u32string_view = basic_string_view< char32_t >
 
using wstring_view = basic_string_view< wchar_t >
 
template<class A , class B >
using disable_if_same_or_derived_t = typename std::enable_if<!std::is_base_of< A, typename std::remove_reference< B >::type >::value >::type
 

Functions

template<class InputIt , class ForwardIt , class BinOp >
void for_each_token (InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinOp binary_op)
 Applys the binary operator to each token in the range [first, last) that is delimited a token in [s_first, s_last). More...
 
template<class InputIt , class Delims , class BinOp >
void for_each_token (InputIt first, InputIt last, const Delims &delims, BinOp binary_op)
 Applys the binary operator to each token in the range [first, last) that is delimited a token in delims. More...
 
template<class T , class U , std::size_t Alignment>
bool operator== (const aligned_allocator< T, Alignment > &, const aligned_allocator< U, Alignment > &)
 
template<class T , class U , std::size_t Alignment>
bool operator!= (const aligned_allocator< T, Alignment > &, const aligned_allocator< U, Alignment > &)
 
template<class T , class BinaryFunction >
fixed_heap< T, BinaryFunction > make_fixed_heap (uint64_t max_elems, BinaryFunction &&bf)
 Constructs a fixed_heap from a maximum size and binary comparison function.
 
template<class HashAlgorithm , class Tag , class T >
void hash_append (HashAlgorithm &h, const identifier< Tag, T > &id)
 
template<class Iterator , class UnaryFunction >
transform_iterator< Iterator, UnaryFunction > make_transform_iterator (Iterator it, UnaryFunction &&fun)
 Helper function to construct a transform_iterator from an Iterator and a UnaryFunction to transform the values of that Iterator.
 
template<class ForwardIterator , class RecordHandler , class Compare , class ShouldMerge , class ProgressTrait = printing::default_progress_trait>
uint64_t multiway_merge (ForwardIterator begin, ForwardIterator end, Compare &&record_comp, ShouldMerge &&should_merge, RecordHandler &&output, ProgressTrait=ProgressTrait{})
 A generic algorithm for performing an N-way merge on a collection of sorted "chunks". More...
 
template<class ForwardIterator , class RecordHandler , class ProgressTrait = printing::default_progress_trait>
uint64_t multiway_merge (ForwardIterator begin, ForwardIterator end, RecordHandler &&output, ProgressTrait=ProgressTrait{})
 A simplified wrapper for multiway_merge that uses the default comparison (operator<) and merge criteria (operator==).
 
template<class Record >
bool operator!= (const chunk_iterator< Record > &a, const chunk_iterator< Record > &b)
 
template<class T >
bool operator< (const optional< T > &lhs, const optional< T > &rhs)
 
template<class T >
basic_range< T > range (const T &begin, const T &end)
 Constructs a range based on a beginning and ending value. More...
 
template<class T >
basic_range< T > range (const T &begin, const T &end, const T &step)
 Constructs a range based on a beginning value, and ending value, and a step size. More...
 
template<class Index , class Value >
sparse_vector< Index, Value > operator+ (const sparse_vector< Index, Value > &lhs, const sparse_vector< Index, Value > &rhs)
 
template<class Index , class Value >
sparse_vector< Index, Value > operator+ (sparse_vector< Index, Value > &&lhs, const sparse_vector< Index, Value > &rhs)
 
template<class Index , class Value >
sparse_vector< Index, Value > operator+ (const sparse_vector< Index, Value > &lhs, sparse_vector< Index, Value > &&rhs)
 
template<class Index , class Value >
sparse_vector< Index, Value > operator+ (sparse_vector< Index, Value > &&lhs, sparse_vector< Index, Value > &&rhs)
 
template<class Index , class Value >
sparse_vector< Index, Value > operator- (const sparse_vector< Index, Value > &lhs, const sparse_vector< Index, Value > &rhs)
 
template<class Index , class Value >
sparse_vector< Index, Value > operator- (sparse_vector< Index, Value > &&lhs, const sparse_vector< Index, Value > &rhs)
 
template<class Index , class Value >
sparse_vector< Index, Value > operator- (sparse_vector< Index, Value > &&lhs, sparse_vector< Index, Value > &&rhs)
 
template<class SparseVector1 , class SparseVector2 >
double dot_product (SparseVector1 &&first, SparseVector2 &&second)
 
template<class Char , class Traits >
constexpr bool operator== (basic_string_view< Char, Traits > lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator== (basic_string_view< Char, Traits > lhs, identity< basic_string_view< Char, Traits >> rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator== (identity< basic_string_view< Char, Traits >> lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator!= (basic_string_view< Char, Traits > lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator!= (basic_string_view< Char, Traits > lhs, identity< basic_string_view< Char, Traits >> rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator!= (identity< basic_string_view< Char, Traits >> lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator< (basic_string_view< Char, Traits > lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator< (basic_string_view< Char, Traits > lhs, identity< basic_string_view< Char, Traits >> rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator< (identity< basic_string_view< Char, Traits >> lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator> (basic_string_view< Char, Traits > lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator> (basic_string_view< Char, Traits > lhs, identity< basic_string_view< Char, Traits >> rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator> (identity< basic_string_view< Char, Traits >> lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator<= (basic_string_view< Char, Traits > lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator<= (basic_string_view< Char, Traits > lhs, identity< basic_string_view< Char, Traits >> rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator<= (identity< basic_string_view< Char, Traits >> lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator>= (basic_string_view< Char, Traits > lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator>= (basic_string_view< Char, Traits > lhs, identity< basic_string_view< Char, Traits >> rhs) noexcept
 
template<class Char , class Traits >
constexpr bool operator>= (identity< basic_string_view< Char, Traits >> lhs, basic_string_view< Char, Traits > rhs) noexcept
 
template<class Char , class Traits >
std::basic_ostream< Char, Traits > & operator<< (std::basic_ostream< Char, Traits > &os, basic_string_view< Char, Traits > str)
 
string_view make_string_view (std::string::const_iterator begin, std::string::const_iterator end)
 

Variables

constexpr struct meta::util::trivial_init_t trivial_init
 
constexpr nullopt_t nullopt {nullopt_t::init{}}
 A global nullopt_t constant.
 

Detailed Description

Shared resources and utilities.

Typedef Documentation

§ clonable

template<class Base , class Derived >
using meta::util::clonable = typedef multilevel_clonable<Base, Base, Derived>

Template alias to facilitate polymorphic cloning.

Use in place of an ordinary base class, with first parameter being the base class and the second parameter being the current class (CRTP style).

Function Documentation

§ for_each_token() [1/2]

template<class InputIt , class ForwardIt , class BinOp >
void meta::util::for_each_token ( InputIt  first,
InputIt  last,
ForwardIt  s_first,
ForwardIt  s_last,
BinOp  binary_op 
)

Applys the binary operator to each token in the range [first, last) that is delimited a token in [s_first, s_last).

See also
http://tristanbrindle.com/posts/a-quicker-study-on-tokenising/

§ for_each_token() [2/2]

template<class InputIt , class Delims , class BinOp >
void meta::util::for_each_token ( InputIt  first,
InputIt  last,
const Delims &  delims,
BinOp  binary_op 
)

Applys the binary operator to each token in the range [first, last) that is delimited a token in delims.

See also
http://tristanbrindle.com/posts/a-quicker-study-on-tokenising/

§ multiway_merge()

template<class ForwardIterator , class RecordHandler , class Compare , class ShouldMerge , class ProgressTrait = printing::default_progress_trait>
uint64_t meta::util::multiway_merge ( ForwardIterator  begin,
ForwardIterator  end,
Compare &&  record_comp,
ShouldMerge &&  should_merge,
RecordHandler &&  output,
ProgressTrait  = ProgressTrait{} 
)

A generic algorithm for performing an N-way merge on a collection of sorted "chunks".

The following concepts are involved:

  • Record: A Record must represent the atomic items that are to be merged. They must have a member function merge_with(Record&&). During the merging process, Records will be read from the individual chunks (via ChunkIterator::operator++), merge_with will be called across all Records across all chunks that should merge according to the predicate specified (defaulting to operator==), and the final merged Record will be passed to the write callback.
  • ForwardIterator: A basic ForwardIterator whose value type must model the ChunkIterator concept.
  • ChunkIterator: A ChunkIterator is an iterator over Records within a chunk. Typically, these will be streamed-in from disk, and thus ChunkIterator can be thought of as an InputIterator with a few additional functions.

    ChunkIterators must dereference to a Record.

    Comparison operators for (in)equality must be provided. A ChunkIterator that cannot read any more Records must compare equal to the default-constructed ChunkIterator.

    ChunkIterator's operator++ shall buffer in (at least) the next Record, which can be obtained via the dereference operator.

    ChunkIterators also keep track of the state of the underlying InputStream from which Records are read. ChunkIterators shall provide two observer functions for the state of that stream: total_bytes(), which indicates the total number of bytes that occur in the stream, and bytes_read(), which indicates the total number of bytes that have been consumed from the stream thus far. When bytes_read() == total_bytes(), the stream has been exhausted and the iterator shall compare equal to the default-constructed ChunkIterator.

  • Compare: A simple comparison function to be used for sorting the records. Defaults to operator<.
  • ShouldMerge: A binary function that returns true if the two records given to it as arguments should be merged together via Record::merge_with(). Defaults to operator==.
  • RecordHandler: A unary function that is called once per every unique Record after merging.
  • ProgressTrait: A traits class whose type indicates the progress reporting object to use. By default, this is meta::printing::default_progress_trait, but progress reporting can be silenced using meta::printing::no_progress_trait.
Returns
the total number of unique Records that were written to the OutputStream

§ range() [1/2]

template<class T >
basic_range<T> meta::util::range ( const T &  begin,
const T &  end 
)

Constructs a range based on a beginning and ending value.

Parameters
beginThe desired start for the range
endThe desired end for the range
Returns
a new range between begin and end

§ range() [2/2]

template<class T >
basic_range<T> meta::util::range ( const T &  begin,
const T &  end,
const T &  step 
)

Constructs a range based on a beginning value, and ending value, and a step size.

Parameters
beginThe desired start for the range
endThe desired end for the range
stepThe desired step size for the range
Returns
a new range between begin and end that increments by step each time