Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::AlDomain< T > Class Template Reference

Generic domain class based on hash set. More...

#include <al-domain.H>

Inheritance diagram for Aleph::AlDomain< T >:
[legend]
Collaboration diagram for Aleph::AlDomain< T >:
[legend]

Public Types

using Base = Aleph::HashSet< T, SetODhash >
 
typedef HashSetTable< Key, Cmp > Base
 
- Public Types inherited from Aleph::HashSet< Key, HashSetTable, Cmp >
typedef HashSetTable< Key, Cmp > Base
 

Public Member Functions

const DynList< T > & keys () const
 Get sorted list of all elements in the domain.
 
DynList< Tto_list () const
 Convert domain to sorted list.
 
std::string to_str () const
 Convert domain to string representation.
 
- Public Member Functions inherited from Aleph::HashSet< Key, HashSetTable, Cmp >
void add (const DynList< Key > &l)
 
template<template< typename > class List>
 HashSet (const List< Key > &l)
 
template<class It >
 HashSet (It b, It e)
 
 HashSet (std::initializer_list< Key > l)
 
 HashSet ()
 
Key & get_first () const
 
Key & get_last () const
 

Private Attributes

bool keys_build = false
 Lazy cache flag.
 
DynList< Tdomain
 Cached sorted keys.
 

Detailed Description

template<typename T = int>
class Aleph::AlDomain< T >

Generic domain class based on hash set.

Stores a set of unique elements with O(1) lookup. Provides sorted iteration via the keys() method.

Template Parameters
TElement type (default: int)

Definition at line 84 of file al-domain.H.

Member Typedef Documentation

◆ Base [1/2]

template<typename T = int>
using Aleph::AlDomain< T >::Base = Aleph::HashSet<T, SetODhash>

Definition at line 91 of file al-domain.H.

◆ Base [2/2]

template<typename T = int>
typedef HashSetTable<Key, Cmp> Aleph::HashSet< Key, HashSetTable, Cmp >::Base

Definition at line 64 of file tpl_hash.H.

Member Function Documentation

◆ keys()

template<typename T = int>
const DynList< T > & Aleph::AlDomain< T >::keys ( ) const
inline

Get sorted list of all elements in the domain.

Lazily builds and caches the sorted key list.

Returns
Const reference to sorted DynList of elements

Definition at line 101 of file al-domain.H.

References Aleph::AlDomain< T >::domain, Aleph::AlDomain< T >::keys_build, Aleph::maps(), and Aleph::sort().

Referenced by TEST(), TEST_F(), and Aleph::AlDomain< T >::to_list().

◆ to_list()

template<typename T = int>
DynList< T > Aleph::AlDomain< T >::to_list ( ) const
inline

Convert domain to sorted list.

Returns
Sorted DynList of all elements

Definition at line 115 of file al-domain.H.

References Aleph::AlDomain< T >::keys().

Referenced by TEST_F(), and Aleph::AlDomain< T >::to_str().

◆ to_str()

template<typename T = int>
std::string Aleph::AlDomain< T >::to_str ( ) const
inline

Convert domain to string representation.

Returns
Space-separated string of sorted elements

Definition at line 121 of file al-domain.H.

References Aleph::maps(), Aleph::sort(), Aleph::AlDomain< T >::to_list(), and Aleph::to_str().

Member Data Documentation

◆ domain

template<typename T = int>
DynList<T> Aleph::AlDomain< T >::domain
mutableprivate

Cached sorted keys.

Definition at line 87 of file al-domain.H.

Referenced by Aleph::AlDomain< T >::keys().

◆ keys_build

template<typename T = int>
bool Aleph::AlDomain< T >::keys_build = false
mutableprivate

Lazy cache flag.

Definition at line 86 of file al-domain.H.

Referenced by Aleph::AlDomain< T >::keys().


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