22#include <QtCore/QSharedData> 
   24using namespace KIMAP2;
 
   35    Private(
const Private &other) :
 
   50    Private(
const Private &other) :
 
   53        intervals = other.intervals;
 
   76ImapInterval::~ ImapInterval()
 
 
   90    return (d->begin == other.d->begin && d->end == other.d->end);
 
 
   95    if (!d->begin && !d->end) {
 
   98    if (d->begin && !d->end) {
 
   99        return Q_INT64_C(0x7FFFFFFFFFFFFFFF) - d->begin + 1;
 
  101    return d->end - d->begin + 1;
 
 
  106    return d->begin != 0;
 
 
  129    Q_ASSERT(value >= 0);
 
 
  136    Q_ASSERT(value >= 0);
 
 
  167    Id begin = values[0].toLongLong(&ok);
 
  175    if (values.
size() == 1) {
 
  181        end = values[1].toLongLong(&ok);
 
 
  218    if (
this != &other) {
 
 
  226    if (d->intervals.size() != other.d->intervals.size()) {
 
  231        if (!other.d->intervals.contains(interval)) {
 
 
  247    std::sort(vals.
begin(), vals.
end());
 
  248    for (
auto i = 0; i < vals.
count(); ++i) {
 
  249        const auto begin = vals[i];
 
  250        Q_ASSERT(begin >= 0);
 
  251        if (i == vals.
count() - 1) {
 
  257            Q_ASSERT(vals[i] >= 0);
 
  258            if (vals[i] != (vals[i - 1] + 1)) {
 
  262        } 
while (i < vals.
count() - 1);
 
 
  269    d->intervals << interval;
 
 
  275    rv.
reserve(d->intervals.count());
 
  287            result += 
',' + (*it);
 
 
  316    return d->intervals.isEmpty();
 
 
  322    if (d->intervals.size() < 2) {
 
  327    std::sort(d->intervals.begin(), d->intervals.end(),
 
  329                   return lhs.begin() < rhs.begin();
 
  332    auto it = d->intervals.begin();
 
  333    while (it != d->intervals.end() && it != std::prev(d->intervals.end())) {
 
  334        auto next = std::next(it);
 
  336        if (it->hasDefinedEnd() && it->end() + 1 >= next->begin()) {
 
  337            next->setBegin(it->begin());
 
  338            if (next->hasDefinedEnd() && it->end() > next->end()) {
 
  339                next->setEnd(it->end());
 
  341            it = d->intervals.erase(it);
 
  342        } 
else if (!it->hasDefinedEnd()) {
 
  344            it = d->intervals.erase(next, d->intervals.end());
 
 
Represents a single interval in an ImapSet.
 
bool hasDefinedBegin() const
Returns true if this interval has a defined begin.
 
ImapInterval()
Constructs an interval that covers all positive numbers.
 
ImapInterval & operator=(const ImapInterval &other)
Assignment operator.
 
static ImapInterval fromImapSequence(const QByteArray &sequence)
Return the interval corresponding to the given IMAP-compatible QByteArray representation.
 
Id end() const
Returns the end of this interval.
 
qint64 Id
Describes the ids stored in the interval.
 
Id begin() const
Returns the begin of this interval.
 
void setEnd(Id value)
Sets the end of this interval.
 
Id size() const
Returns the size of this interval.
 
bool operator==(const ImapInterval &other) const
Comparison operator.
 
bool hasDefinedEnd() const
Returns true if this intercal has been defined.
 
void setBegin(Id value)
Sets the begin of the interval.
 
QList< ImapInterval > List
A list of ImapInterval objects.
 
QByteArray toImapSequence() const
Converts this set into an IMAP compatible sequence.
 
Represents a set of natural numbers (1->∞) in a as compact as possible form.
 
bool isEmpty() const
Returns true if this set doesn't contains any values.
 
ImapSet()
Constructs an empty set.
 
void optimize()
Optimizes the ImapSet by sorting and merging overlapping intervals.
 
qint64 Id
Describes the ids stored in the set.
 
QByteArray toImapSequenceSet() const
Returns a IMAP-compatible QByteArray representation of this set.
 
void add(Id value)
Adds a single positive integer numbers to the set.
 
static ImapSet fromImapSequenceSet(const QByteArray &sequence)
Return the set corresponding to the given IMAP-compatible QByteArray representation.
 
bool operator==(const ImapSet &other) const
Comparison operator.
 
ImapInterval::List intervals() const
Returns the intervals this set consists of.
 
ImapSet & operator=(const ImapSet &other)
Assignment operator.
 
bool isEmpty() const const
 
QByteArray number(double n, char format, int precision)
 
QList< QByteArray > split(char sep) const const
 
const_iterator constBegin() const const
 
const_iterator constEnd() const const
 
qsizetype count() const const
 
bool isEmpty() const const
 
void reserve(qsizetype size)
 
qsizetype size() const const