seq-range-array.c revision 90b50df264b57e0f63cd8cc6aea1ce3bb7cf5f64
/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "seq-range-array.h"
{
/* it's already in the range */
return TRUE;
}
} else {
}
}
return FALSE;
}
{
if (!array_is_created(array))
if (count == 0) {
return;
}
/* quick checks */
/* grow last range */
return;
}
return;
}
/* grow down first range */
return;
}
return;
}
/* somewhere in the middle, array is sorted so find it with
binary search */
return;
idx++;
/* idx == count couldn't happen because we already handle it above */
/* merge */
}
/* merge */
}
} else {
}
}
{
if (!array_is_created(array))
return FALSE;
if (count == 0)
return FALSE;
/* quick checks */
/* outside the range */
return FALSE;
}
/* shrink last range */
else
return TRUE;
}
/* shrink up first range */
else
return TRUE;
}
/* somewhere in the middle, array is sorted so find it with
binary search */
else {
/* found it */
/* a single sequence range.
remove it entirely */
} else {
/* shrink the range */
}
/* shrink the range */
} else {
/* split the sequence range */
}
return TRUE;
}
}
return FALSE;
}
{
/* remove first and last. this makes sure that everything between
can simply be deleted with array_delete().
FIXME: it would be faster if we did only one binary lookup here
and handled the splitting ourself.. */
remove_count++;
return remove_count;
remove_count++;
return remove_count;
/* find the beginning */
idx++;
return remove_count;
break;
}
return remove_count;
}
{
unsigned int idx;
}
{
unsigned int i, count;
if (array_is_created(array))
else {
count = 0;
}
if (count == 0) {
/* empty -> full */
if (!array_is_created(array))
return;
}
/* full -> empty */
return;
}
for (i = 0; i < count; ) {
} else {
i++;
}
}
}
}