AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

2 dimensionale sets?

Ein Thema von dajuhsa · begonnen am 16. Mär 2008 · letzter Beitrag vom 17. Mär 2008
 
Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#9

Re: 2 dimensionale sets?

  Alt 16. Mär 2008, 17:54
Ein Bitvektor ist im Prinzip das, was die Pascal/Delphi-Sets machen oder auch die Klasse TBits: Man benutzt einfach einzelne Bits, um einen Boolean-Wert zu speichern.

In einem 32-Bit-Cardinal hat man z.B. 32 Bits, kann also 32 Booleans darin kodieren. Realisiert wird das über die binären Operatoren von Delphi.

Zum Abfragen eines Bits verwendet man sowas:

Delphi-Quellcode:
function GetBit(const Vector, Index: Cardinal): Boolean;
begin
  Result:=Vector and (1 shl Index)>0;
end;
Und zum Setzen:

Delphi-Quellcode:
procedure SetBit(var Vector: Cardinal; const Index: Cardinal; const Value: Boolean);
begin
  if Value then
    Vector:=Vector or (1 shl Index)
  else
    Vector:=Vector and not (1 shl Index);
end;
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:14 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz