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

Policy: count distinct elements in a range. More...

#include <tpl_mo_algorithm.H>

Collaboration diagram for Aleph::Distinct_Count_Policy< T >:
[legend]

Public Types

using answer_type = size_t
 

Public Member Functions

void init (const Array< T > &, size_t)
 
void add (const Array< T > &data, size_t idx)
 
void remove (const Array< T > &data, size_t idx)
 
answer_type answer () const
 

Public Attributes

MapOLhash< T, size_t > freq
 
size_t distinct = 0
 

Detailed Description

template<typename T>
struct Aleph::Distinct_Count_Policy< T >

Policy: count distinct elements in a range.

Maintains a frequency map and a running distinct count. add: if freq goes from 0 to 1, increment count. remove: if freq goes from 1 to 0, decrement count.

Template Parameters
TElement type (must be hashable).

Definition at line 411 of file tpl_mo_algorithm.H.

Member Typedef Documentation

◆ answer_type

template<typename T >
using Aleph::Distinct_Count_Policy< T >::answer_type = size_t

Definition at line 413 of file tpl_mo_algorithm.H.

Member Function Documentation

◆ add()

template<typename T >
void Aleph::Distinct_Count_Policy< T >::add ( const Array< T > &  data,
size_t  idx 
)
inline

◆ answer()

template<typename T >
answer_type Aleph::Distinct_Count_Policy< T >::answer ( ) const
inline

Definition at line 437 of file tpl_mo_algorithm.H.

References Aleph::Distinct_Count_Policy< T >::distinct.

◆ init()

◆ remove()

template<typename T >
void Aleph::Distinct_Count_Policy< T >::remove ( const Array< T > &  data,
size_t  idx 
)
inline

Member Data Documentation

◆ distinct

◆ freq


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