With a table from a database (MS SQL Server). Your table has two fields, the
primary key, an autonumber automatically generated, and the second field, a
nvarchar(255) with an index unique but with ignore_dup_key on.
Insert the new title in the table.
INSERT INTO hashTable(secondFieldName) VALUES('microsoft csharp news
group')
If the title does not exist, it will be appended. If the title exists, it
will be rejected (unique constraint). You can also insert a batch of titles:
INSERT INTO hashTable(secondFieldName) SELECT titles FROM otherTable
and the new titles will be appended, while the existing ones will be
rejected (that is because of the ignore_dup_key set to on; if set to false,
all the 'batch' would be rejected).
Next, to get the hash number, make a 'lookup' over the title, returning the
primary key.
SELECT primaryKey FROM hashTable WHERE secondFieldName='microsoft csharp
news group'
That returns the long integer value that satisfy your definition, even if it
is not a hash value 'per se'. Since the second field is also indexed,
finding the hash value should not be really too slow, even if the hashTable
is large. If two titles are the same, they will return the same 'hash
value', since only one sample of the title would have been saved in the
table (due to the UNIQUE constraint).
Vanderghast, Access MVP.