mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-16 01:57:36 +08:00
add sectorcollection
This commit is contained in:
@ -7,7 +7,7 @@ SectorCollection::SectorCollection()
|
||||
|
||||
}
|
||||
|
||||
void SectorCollection::Add(Sector item)
|
||||
void SectorCollection::Add(const Sector &item)
|
||||
{
|
||||
if (DoCheckSizeLimitReached() == false)
|
||||
return;
|
||||
@ -15,6 +15,12 @@ void SectorCollection::Add(Sector item)
|
||||
add(item);
|
||||
}
|
||||
|
||||
void SectorCollection::Clear()
|
||||
{
|
||||
largeArraySlices.clear();
|
||||
count = 0;
|
||||
}
|
||||
|
||||
bool SectorCollection::DoCheckSizeLimitReached()
|
||||
{
|
||||
if (!sizeLimitReached && (count - 1 > MAX_SECTOR_V4_COUNT_LOCK_RANGE))
|
||||
@ -25,22 +31,22 @@ bool SectorCollection::DoCheckSizeLimitReached()
|
||||
return true;
|
||||
}
|
||||
|
||||
int SectorCollection::add(Sector item)
|
||||
int SectorCollection::add(const Sector &item)
|
||||
{
|
||||
int itemIndex = count / SLICE_SIZE;
|
||||
unsigned itemIndex = count / SLICE_SIZE;
|
||||
|
||||
if (itemIndex < largeArraySlices.Count)
|
||||
{
|
||||
largeArraySlices[itemIndex].Add(item);
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayList ar = new ArrayList(SLICE_SIZE);
|
||||
ar.Add(item);
|
||||
largeArraySlices.Add(ar);
|
||||
count++;
|
||||
}
|
||||
if (itemIndex < largeArraySlices.size())
|
||||
{
|
||||
largeArraySlices[itemIndex]->push_back(item);
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unique_ptr<std::vector<Sector>> ar(new std::vector<Sector>(SLICE_SIZE));
|
||||
ar->emplace_back(item);
|
||||
largeArraySlices.push_back(ar);
|
||||
count++;
|
||||
}
|
||||
|
||||
return count - 1;
|
||||
return count - 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user