Nemiver  0.3
Public Types | Public Member Functions | List of all members
nemiver::common::Range Class Reference

This abstracts a range of integer values. More...

#include <nmv-range.h>

Public Types

enum  ValueSearchResult {
  VALUE_SEARCH_RESULT_EXACT = 0, VALUE_SEARCH_RESULT_WITHIN, VALUE_SEARCH_RESULT_BEFORE, VALUE_SEARCH_RESULT_AFTER,
  VALUE_SEARCH_RESULT_NONE
}
 

Public Member Functions

 Range (size_t a_min=0, size_t a_max=0)
 
size_t min () const
 Accessors of the lower bound of the range. More...
 
void min (size_t a)
 
size_t max () const
 Accessors of the upper bound of the range. More...
 
void max (size_t a)
 
bool contains (size_t a_value) const
 Returns true if a_value is within the range. More...
 
void extend (size_t a_value)
 

Detailed Description

This abstracts a range of integer values.

Member Enumeration Documentation

◆ ValueSearchResult

An enum representing the result of the searching of a range around a value. E.g, suppose we have an ordered set of integer values vi {v1, v2, v3 ...} that we name V. Suppose we also have a particular integer N. And we want to make the query expressed as: "What is the smallest range R{vi,vi+p} that encloses N?". If we had a function that would execute that query and return an answer, this enum would help us know more about the how N relates to the returned range. VALUE_SEARCH_RESULT_EXACT means that the N equals vi and equals vi+p. It means the range is actually a single value, which is N. VALUE_SEARCH_RESULT_WITHIN means that N is greater than vi and less than vi+p. I means N is within the range. VALUE_SEARCH_RESULT_BEFORE means that N is less then vi, and so less than vi+p too. It means N is before the range. VALUE_SEARCH_RESULT_AFTER means N is greater than vi+p, and so greater than vi too. It means N is after the range.

Enumerator
VALUE_SEARCH_RESULT_EXACT 
VALUE_SEARCH_RESULT_WITHIN 
VALUE_SEARCH_RESULT_BEFORE 
VALUE_SEARCH_RESULT_AFTER 
VALUE_SEARCH_RESULT_NONE 

Constructor & Destructor Documentation

◆ Range()

nemiver::common::Range::Range ( size_t  a_min = 0,
size_t  a_max = 0 
)
inline

Member Function Documentation

◆ contains()

bool nemiver::common::Range::contains ( size_t  a_value) const
inline

Returns true if a_value is within the range.

◆ extend()

void nemiver::common::Range::extend ( size_t  a_value)
inline

Extends the range. If a_value is greater than the upper bound of the range, then the range becomes [lower-bound, a_value]. If a_value is less than the lower bound of the range, then the range becomes [a_value, upper-bound]. If a_value is within the range, nothing happens.

◆ max() [1/2]

size_t nemiver::common::Range::max ( ) const
inline

Accessors of the upper bound of the range.

◆ max() [2/2]

void nemiver::common::Range::max ( size_t  a)
inline

◆ min() [1/2]

size_t nemiver::common::Range::min ( ) const
inline

Accessors of the lower bound of the range.

◆ min() [2/2]

void nemiver::common::Range::min ( size_t  a)
inline

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