プログラム言語 FreeBasic |
Function CreateHashTable() As Any Ptr
新しいハッシュテーブルを作成し、そのハンドルを返します。
文字列データにハッシュテーブルを使う場合は、SetValueStrHashTable 関数と GetValueStrHashTable 関数を使います。
FreeHashTable、FreeKeyHashTable、DeleteHashTable 関数は、文字列データメモリを解放するために、最後のパラメータにゼロ以外の値を含める必要があります。
ハッシュテーブルに文字列以外のデータが含まれている場合は、SetValueHashTable、GetValueHashTable 関数を使います。
FreeHashTable、FreeKeyHashTable、DeleteHashTable 関数は、最後のパラメーターにゼロ(デフォルト)を含める必要があります。
同じハッシュテーブルに文字列関数と非文字列関数を混在させることは望ましくありません。
無し
Windows , Linux
#include "window9.bi"
dim p as any ptr = CreateHashTable()
For i As Long = 0 To 10
dim as string skey = "Key" & i
dim as USTRING us = str(rnd)
SetValueStrHashTable(p , skey , us)
Next
For i As Long = 0 To 10
dim as string skey = "Key" & i
? GetValueStrHashTable(p , skey )
Next
DeleteHashTable(p , 1)
Sleep
0.3300995409954339
0.3290384791325778
0.5324827746953815
0.7599449595436454
0.6424803049303591
0.6527107947040349
0.2956116099376231
0.970114589901641
0.9696021103300154
0.9504357760306448
0.5354314723517746