Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.03.25;
Скачать: CL | DM;

Вниз

Как создать в Delphi нестандартный тип? Например ..   Найти похожие ветки 

 
Бурундук   (2002-03-09 23:23) [11]

Можно, конечно, изобрести нечто вроде
(Но я не уверен, что по скорости это тебе подойдёт)

type
PArray = ^TArray;
TArray = array[0..MaxInt div 16]of Int64;
T3BitArray = class
private
FArray: PArray;
FLength: Integer;
FSize: Integer;
public
function Get(I: Integer): Byte;
procedure Put(I: Integer; Value: Byte);
property Elements[I: Integer]: Byte read Get write Put; default;
constructor Create(ALength: Integer);
destructor Destroy; override;
end;

implementation

{----------------------- T3BitArray ---------------------------}

constructor T3BitArray.Create(ALength: Integer);
begin
FLength := ALength;
FSize := Round(ALength*8/21)+1;
ReallocMem(FArray, FSize);
end;

destructor T3BitArray.Destroy;
begin
ReallocMem(FArray, 0);
end;

function T3BitArray.Get(I: Integer): Byte;
var N, b: Integer;
begin
N := I div 21;
b := I mod 21;
Result := (FArray^[N] shr b*3) and $7;
end;

procedure T3BitArray.Put(I: Integer; Value: Byte);
var N, b: Integer;
begin
N := I div 21;
b := I mod 21;
FArray^[N] := ((Value and $7) shl b*3) or ( (not($7 shl b*3))and(FArray^[N]) );
end;



Страницы: 1 вся ветка

Текущий архив: 2002.03.25;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.011 c
1-80589
igorr
2002-03-11 03:09
2002.03.25
Как спозиционировать InputBox или InputQuery?


1-80503
Vladimir K.
2002-03-09 03:25
2002.03.25
Подвисание формы во время выполнения цикла...(#2) RE2ALL


3-80421
dmitriyk
2002-02-26 03:35
2002.03.25
Почему ПОСЛЕДНЯЯ добавленная запись потом выводится ПЕРВОЙ


3-80398
Hawk2
2002-02-25 12:51
2002.03.25
Помогите с ADO.


14-80673
.: Joiro :.
2002-02-10 23:42
2002.03.25
Продолжаем/дополняем тему о фильмах: Какой фильм Вы больше всего ждёте?