Classes | Functions
lazy_list.hpp File Reference

Lazily evaluated list. More...

#include <cassert>
#include "universal_error.hpp"
#include <algorithm>
Include dependency graph for lazy_list.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  LazyList< T >
 Ordered list whose terms are evaluated lazily. More...
 
class  Echo< T >
 Converts a vector to a lazy list. More...
 
class  ContiguousChunk< T >
 Creates a contiguous chunk of a lazy list. More...
 

Functions

template<class T >
vector< T > serial_generate (const LazyList< T > &ll)
 Creates a vector from an LazyList. More...
 
template<class T >
vector< T > termwise_product (const vector< T > &v, const T &s)
 Multiplies all terms of std::vector with a scalar. More...
 
template<class T >
vector< T > trim_top (const vector< T > &v, const size_t max_index)
 Trims a list and retains only a specific number of the first terms. More...
 
template<class T >
int ElementNumber (vector< vector< T > > const &vec)
 Calculates the total number of elements in the 2d vector. More...
 
template<class T >
void ListExchange (vector< T > &vec, vector< int > const &indeces, vector< T > const &data)
 Exchanges memebers in vec with indeces given by indeces and data given by data. More...
 
template<class T >
lazy_sum (const LazyList< T > &i2m)
 Sums terms of a lazy list. More...
 
template<class T >
lazy_max (const LazyList< T > &i2m)
 Finds the maximum of a lazy list. More...
 
template<class T >
lazy_min (const LazyList< T > &i2m)
 Finds the minimum of a lazy list. More...
 

Detailed Description

Lazily evaluated list.

Author
Almog Yalinewich

Definition in file lazy_list.hpp.

Function Documentation

◆ ElementNumber()

template<class T >
int ElementNumber ( vector< vector< T > > const &  vec)

Calculates the total number of elements in the 2d vector.

Parameters
vecThe vector to count
Returns
The number of elements

Definition at line 130 of file lazy_list.hpp.

Here is the call graph for this function:

◆ lazy_max()

template<class T >
T lazy_max ( const LazyList< T > &  i2m)

Finds the maximum of a lazy list.

Parameters
i2mLazy list
Returns
Max term of lazy list

Definition at line 174 of file lazy_list.hpp.

Here is the call graph for this function:

◆ lazy_min()

template<class T >
T lazy_min ( const LazyList< T > &  i2m)

Finds the minimum of a lazy list.

Parameters
i2mLazy list
Returns
Min term of lazy list

Definition at line 186 of file lazy_list.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lazy_sum()

template<class T >
T lazy_sum ( const LazyList< T > &  i2m)

Sums terms of a lazy list.

Parameters
i2mlazy list
Returns
Sum of all terms of i2m

Definition at line 162 of file lazy_list.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ListExchange()

template<class T >
void ListExchange ( vector< T > &  vec,
vector< int > const &  indeces,
vector< T > const &  data 
)

Exchanges memebers in vec with indeces given by indeces and data given by data.

Parameters
vecThe vector to change
indecesThe indeces in vec to change
dataThe data to put inside vec

Definition at line 144 of file lazy_list.hpp.

Here is the call graph for this function:

◆ serial_generate()

template<class T >
vector<T> serial_generate ( const LazyList< T > &  ll)

Creates a vector from an LazyList.

Parameters
llLazily evaluated list
Returns
std::vector

Definition at line 49 of file lazy_list.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ termwise_product()

template<class T >
vector<T> termwise_product ( const vector< T > &  v,
const T &  s 
)

Multiplies all terms of std::vector with a scalar.

Parameters
vstd::vector
sScalar
Returns
Each term of v multiplied by s

Definition at line 62 of file lazy_list.hpp.

Here is the call graph for this function:

◆ trim_top()

template<class T >
vector<T> trim_top ( const vector< T > &  v,
const size_t  max_index 
)

Trims a list and retains only a specific number of the first terms.

Parameters
vstd::vector
max_indexNumber of terms to retain
Returns
The first max_index number of terms from v

Definition at line 96 of file lazy_list.hpp.

Here is the call graph for this function: