Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::IntRange Struct Reference

Integer range domain [start, end] with optional step. More...

#include <al-domain.H>

Inheritance diagram for Aleph::IntRange:
[legend]
Collaboration diagram for Aleph::IntRange:
[legend]

Public Member Functions

 IntRange ()=delete
 Deleted default constructor (range required)
 
 IntRange (const int start, const int end, const int step=1)
 Construct range [start, end] with step.
 
 IntRange (const size_t n)
 Construct range [0, n-1].
 
- Public Member Functions inherited from Aleph::AlDomain< int >
const DynList< int > & keys () const
 Get sorted list of all elements in the domain.
 
DynList< int > to_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
 

Additional Inherited Members

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

Detailed Description

Integer range domain [start, end] with optional step.

Specialized domain for integer ranges, commonly used as indices for sparse matrices and vectors.

Construction Examples

Constructor Result
IntRange(5) {0, 1, 2, 3, 4}
IntRange(0, 4) {0, 1, 2, 3, 4}
IntRange(0, 10, 2) {0, 2, 4, 6, 8, 10}

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

Constructor & Destructor Documentation

◆ IntRange() [1/3]

Aleph::IntRange::IntRange ( )
delete

Deleted default constructor (range required)

◆ IntRange() [2/3]

Aleph::IntRange::IntRange ( const int  start,
const int  end,
const int  step = 1 
)
inline

Construct range [start, end] with step.

Parameters
startFirst value in range
endLast value in range (inclusive)
stepIncrement between values (default 1)
Exceptions
std::domain_errorif step is negative
Example
IntRange r(0, 10, 2); // {0, 2, 4, 6, 8, 10}
Integer range domain [start, end] with optional step.
Definition al-domain.H:162

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

References ah_domain_error_if, and Aleph::maps().

◆ IntRange() [3/3]

Aleph::IntRange::IntRange ( const size_t  n)
inline

Construct range [0, n-1].

Parameters
nNumber of elements (0 to n-1)
Example
IntRange r(5); // {0, 1, 2, 3, 4}

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


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