AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Hashtable, wie benutzen?

Ein Thema von isilive · begonnen am 28. Mär 2012 · letzter Beitrag vom 25. Apr 2012
 
Horst_

Registriert seit: 22. Jul 2004
Ort: Münster Osnabrück
116 Beiträge
 
#17

AW: Hashtable, wie benutzen?

  Alt 24. Apr 2012, 09:10
Hallo,

ich bekomme den Fehler auch nicht hin
Ich habe mal DictFind.pas geändert.
Es wird jetzt eine lineare Liste erzwungen.
Delphi-Quellcode:
function myRandom(i : TDictIntType):TDictIntType;inline;
begin
  result := i*ccInitialSize+17;//random(i);
end;
denn alle erzeugten Zahlen Wert sind verschieden, aber (Wert mod ccInitialSize) = 17.
Delphi-Quellcode:
program DictFind;
{$IFDEF FPC}
  {$MODE DELPHI}
  {$OPTIMIZATION ON}
  {$OPTIMIZATION REGVAR}
  {$OPTIMIZATION PEEPHOLE}
  {$OPTIMIZATION CSE}
  {$OPTIMIZATION ASMCSE}
{$ELSE}
  {$APPTYPE CONSOLE}
{$ENDIF}

uses
  sysutils,csDictionary;
  
const
  LAENGE = 25*1000*1000;
  RANDOMRANGE = 1000*100;
// RANDOMRANGE = High(tDictIntType);

type
  tArr64 = array of TDictIntType;
var
   t1,t0,dt : TDateTime;
   Wert : TDictIntType;
   dummy : Pointer;
   i,j: integer;

   A64 : tarr64;
   TestHash : TIntegerDictionary;
   
function myRandom(i : TDictIntType):TDictIntType;inline;
begin
  result := i*ccInitialSize+17;//random(i);
end;

BEGIN
  randomize;
  setlength(A64 ,LAENGE);
  TestHash:= TIntegerDictionary.create;

  t0 := time;
  For i := low(A64) to High(A64) do
    Wert := myrandom(i);//random(RANDOMRANGE);
    
  t1 := time;
  dt := t1-t0;
  Write('Erzeugen von ',LAENGE,' Zufallszahlen [0..',Randomrange-1);
  writeln(FormatDateTime('] hh:nn:ss,zzz',dt));

  t0 := time;
  j := low(A64);
  For i := low(A64) to High(A64) do
    begin
    Wert := myrandom(i);//myrandom(RANDOMRANGE);
    IF TestHash.Add(Wert,Pointer(j)) then
      begin
      A64[j] := Wert;
      inc(j);
      end;
    end;
  setlength(A64,j);
  t1 := time;
  Write('TotalCOunt :',TestHash.TotalCount:10);
  Write('Einfuegen von ',j,' verschiedenen Daten in ');
  writeln(FormatDateTime(' hh:nn:ss,zzz',t1-t0-dt));

  For i := low(A64) to 10 do
    writeln(i:10,A64[i]:20,TestHash.find(A64[i],dummy):8,integer(dummy):10);
  writeln(j-1:10,A64[j-1]:20,TestHash.find(A64[j-1],dummy):8,integer(dummy):10);
  t0 := time;
  testHash.free;
  t1 := time;
  Write('Aufloesen der Hashmap in ');
  Writeln(FormatDateTime('hh:nn:ss,zzz',t1-t0));
  setlength(A64,0);
  readln;
END.
Ich erhalte auch so keine Fehlermeldung mit Freepascal 2.6.0 /Win7

Gruß Horst
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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:48 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz