Форум: "Прочее";
Текущий архив: 2013.04.14;
Скачать: [xml.tar.bz2];
Внизоптимальна скорость доступа к массиву Найти похожие ветки
← →
brother © (2012-12-18 10:34) [40]пока остановился на вот таком варианте:
...
TValue = array [0..DictValueLength - 1] of byte;
TItem = record
Value: TValue;
Count: Int64;
CRC32: cardinal;
end;
TItems = array of TItem;
...
Dict: array [0..255] of TItems;
...
procedure TXXX.ItemAdd(Value: TValue);
procedure _Add(id: byte; Value: TValue; crc: cardinal);
begin
SetLength(Dict[id], High(Dict[id])+2);
Dict[id][High(Dict[id])].Value:= Value;
Dict[id][High(Dict[id])].Count:= 0;
Dict[id][High(Dict[id])].CRC32:= crc;
end;
var
n: int64;
max: int64;
crc: cardinal;
id: byte;
begin
id:= Value[0];
max:= High(Dict[id]);
crc:= GetCRC32(Value);
if max > 0 then
begin
n:= 0;
repeat
// anee crc niaiaaa?o e ia eieeecey
if (crc = Dict[id][n].CRC32) and
(CompareMem(@Dict[id][n].Value, @Value, DictValueLength)) then
begin
Inc(Dict[id][n].Count);
Exit;
end;
Inc(n);
until n > Max;
_Add(id, Value, crc);
end
else
_Add(id, Value, crc);
end;
...
для тестов алгоритмов, скорость устраивает...
Страницы: 1 2 вся ветка
Форум: "Прочее";
Текущий архив: 2013.04.14;
Скачать: [xml.tar.bz2];
Память: 0.51 MB
Время: 0.004 c