Loading...
Searching...
No Matches
juce::SparseSet< Type > Class Template Reference

`#include <juce_SparseSet.h>`

## Public Member Functions

| SparseSet (const SparseSet &)=default
SparseSet & | operator= (const SparseSet &)=default
| SparseSet (SparseSet &&other) noexcept
SparseSet & | operator= (SparseSet &&other) noexcept
void | clear ()
bool | isEmpty () const noexcept
Type | size () const noexcept
Type | operator[] (Type index) const noexcept
bool | contains (Type valueToLookFor) const noexcept
int | getNumRanges () const noexcept
Range< Type > | getRange (int rangeIndex) const noexcept
Range< Type > | getTotalRange () const noexcept
void | addRange (Range< Type > range)
void | removeRange (Range< Type > rangeToRemove)
void | invertRange (Range< Type > range)
bool | overlapsRange (Range< Type > range) const noexcept
bool | containsRange (Range< Type > range) const noexcept
const Array< Range< Type > > & | getRanges () const noexcept
bool | operator== (const SparseSet &other) const noexcept
bool | operator!= (const SparseSet &other) const noexcept

## Detailed Description

template<class Type>
class juce::SparseSet< Type >

Holds a set of primitive values, storing them as a set of ranges.

This container acts like an array, but can efficiently hold large contiguous ranges of values. It's quite a specialised class, mostly useful for things like keeping the set of selected rows in a listbox.

The type used as a template parameter must be an integer type, such as int, short, int64, etc.

Definition at line 40 of file juce_SparseSet.h.

## Constructor & Destructor Documentation

## SparseSet()

template<class Type>

juce::SparseSet< Type >::SparseSet | ( | SparseSet< Type > && | other | ) |

inline noexcept

Definition at line 49 of file juce_SparseSet.h.

## Member Function Documentation

## addRange()

template<class Type>

void juce::SparseSet< Type >::addRange | ( | Range< Type > | range | ) |

inline

Adds a range of contiguous values to the set. e.g. addRange (Range <int> (10, 14)) will add (10, 11, 12, 13) to the set.

Definition at line 143 of file juce_SparseSet.h.

Referenced by invertRange().

## clear()

template<class Type>

void juce::SparseSet< Type >::clear | ( |  | ) |

inline

Clears the set.

Definition at line 54 of file juce_SparseSet.h.

## contains()

template<class Type>

bool juce::SparseSet< Type >::contains | ( | Type | valueToLookFor | ) | const

inline noexcept

Checks whether a particular value is in the set.

Definition at line 100 of file juce_SparseSet.h.

## containsRange()

template<class Type>

bool juce::SparseSet< Type >::containsRange | ( | Range< Type > | range | ) | const

inline noexcept

Checks whether the whole of a given range is contained within this one.

Definition at line 231 of file juce_SparseSet.h.

## getNumRanges()

template<class Type>

int juce::SparseSet< Type >::getNumRanges | ( |  | ) | const

inline noexcept

Returns the number of contiguous blocks of values.

See also
  getRange

Definition at line 118 of file juce_SparseSet.h.

## getRange()

template<class Type>

Range< Type > juce::SparseSet< Type >::getRange | ( | int | rangeIndex | ) | const

inline noexcept

Returns one of the contiguous ranges of values stored.

Parameters

  rangeIndex | the index of the range to look up, between 0 and (getNumRanges() - 1)

See also
  getTotalRange

Definition at line 125 of file juce_SparseSet.h.

## getRanges()

template<class Type>

const Array< Range< Type > > & juce::SparseSet< Type >::getRanges | ( |  | ) | const

inline noexcept

Returns the set as a list of ranges, which you may want to iterate over.

Definition at line 242 of file juce_SparseSet.h.

## getTotalRange()

template<class Type>

Range< Type > juce::SparseSet< Type >::getTotalRange | ( |  | ) | const

inline noexcept

Returns the range between the lowest and highest values in the set.

See also
  getRange

Definition at line 130 of file juce_SparseSet.h.

Referenced by removeRange().

## invertRange()

template<class Type>

void juce::SparseSet< Type >::invertRange | ( | Range< Type > | range | ) |

inline

Does an XOR of the values in a given range.

Definition at line 205 of file juce_SparseSet.h.

## isEmpty()

template<class Type>

bool juce::SparseSet< Type >::isEmpty | ( |  | ) | const

inline noexcept

Checks whether the set is empty. This is much quicker than using (size() == 0).

Definition at line 59 of file juce_SparseSet.h.

## operator!=()

template<class Type>

bool juce::SparseSet< Type >::operator!= | ( | const SparseSet< Type > & | other | ) | const

inline noexcept

Definition at line 246 of file juce_SparseSet.h.

## operator=()

template<class Type>

SparseSet & juce::SparseSet< Type >::operator= | ( | SparseSet< Type > && | other | ) |

inline noexcept

Definition at line 50 of file juce_SparseSet.h.

## operator==()

template<class Type>

bool juce::SparseSet< Type >::operator== | ( | const SparseSet< Type > & | other | ) | const

inline noexcept

Definition at line 245 of file juce_SparseSet.h.

## operator[]()

template<class Type>

Type juce::SparseSet< Type >::operator[] | ( | Type | index | ) | const

inline noexcept

Returns one of the values in the set.

Parameters

  index | the index of the value to retrieve, in the range 0 to (size() - 1).

Returns
  the value at this index, or 0 if it's out-of-range

Definition at line 82 of file juce_SparseSet.h.

## overlapsRange()

template<class Type>

bool juce::SparseSet< Type >::overlapsRange | ( | Range< Type > | range | ) | const

inline noexcept

Checks whether any part of a given range overlaps any part of this set.

Definition at line 220 of file juce_SparseSet.h.

## removeRange()

template<class Type>

void juce::SparseSet< Type >::removeRange | ( | Range< Type > | rangeToRemove | ) |

inline

Removes a range of values from the set. e.g. removeRange (Range<int> (10, 14)) will remove (10, 11, 12, 13) from the set.

Definition at line 158 of file juce_SparseSet.h.

Referenced by addRange(), and invertRange().

## size()

template<class Type>

Type juce::SparseSet< Type >::size | ( |  | ) | const

inline noexcept

Returns the number of values in the set.

Because of the way the data is stored, this method can take longer if there are a lot of items in the set. Use isEmpty() for a quick test of whether there are any items.

Definition at line 67 of file juce_SparseSet.h.

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

- juce_SparseSet.h