Class IntegerSet.

Inherits Garbage

This class contains a set of integers.

A IntegerSet is just a set of nonnegative integers. It can add new members to the set, find its members by value() or index() (sorted by size, with 1 first), look for the largest contained number, and produce an SQL "where" clause matching its contents.

IntegerSet::IntegerSet( const IntegerSet & other )

Constructs a set that's an exact copy of other. This constructor is a little expensive, both in time and space.


Constructs an empty set.

Reimplements Garbage::Garbage().

void IntegerSet::add( const IntegerSet & set )

Adds each value in set to this set.

void IntegerSet::add( uint n1, uint n2 )

Adds all numbers between n1 and n2 to the set, including both n1 and n2.

n1 and n2 must both be nonzero.

void IntegerSet::clear()

Removes all numbers from this set.

bool IntegerSet::contains( const IntegerSet & other ) const

Returns true if this set contains all values in other, and false if not.

bool IntegerSet::contains( uint value ) const

Returns true if value is present in this set, and false if not.

uint IntegerSet::count() const

Returns the number of numbers in this IntegerSet.

EString IntegerSet::csl() const

Returns the contents of this set as a comma-separated list of decimal numbers.

uint IntegerSet::index( uint value ) const

Returns the index of value index, or 0 if value is not in this Set.

If this set contains the UIDs in a mailbox, this function converts from UIDs to MSNs. See Session::msn().

IntegerSet IntegerSet::intersection( const IntegerSet & other ) const

Returns a set containing all values which are contained in both this IntegerSet and in other.

bool IntegerSet::isEmpty() const

Returns true if the set is empty, and false if not.

uint IntegerSet::largest() const

Returns the largest number in this IntegerSet, or 0 if the set is empty.

void IntegerSet::recount() const

This private helper ensures that all blocks have an accurate count of set bits, and that no blocks are empty.

void IntegerSet::remove( const IntegerSet & other )

Removes all values contained in other from this set.

void IntegerSet::remove( uint value )

Removes value from this set. Does nothing unless value is present in the set.

void IntegerSet::remove( uint v1, uint v2 )

Removes v1, v2 and all values between them from this set.

EString IntegerSet::set() const

Returns the contents of this set in IMAP syntax. The shortest possible representation is returned, with strictly increasing values, without repetitions, with ":" and "," as necessary.

If the set is empty, so is the returned string.

uint IntegerSet::smallest() const

Returns the smallest UID in this IntegerSet, or 0 if the set is empty.

uint IntegerSet::value( uint index ) const

Returns the value at index, or 0 if index is greater than count().

If this set contains the UIDs in a mailbox, this function converts from MSNs to UIDs. See Session::uid().

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.