OT4XB - HASHTABLE

This forum is for eXpress++ general support.
Message
Author
User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

OT4XB - HASHTABLE

#1 Post by unixkd »

Hi ALL

Anybody with an example code of how to use these OT4XB hashtable functions:

_HDICT_ITERATE_STEP(ht,@pIterator,@item,@key)

_HDICT_ITERATE_STEP(ht, codeblock , @cargo)

Thanks.

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: OT4XB - HASHTABLE

#2 Post by patito »

Hi
Here is an example
There is a manual, which explains its use, go to the page of xbwin

Best Regard
Héctor

#include "ot4xb.ch"
#define MYLOOP 1000
// ---------------------------------------------------------------------------
function Main()
local nSeconds := Seconds()
local oDict := THDict():New(10000000)
local hh := oDict:_m__pHt_
local n,nn
oDict:Pablo := "Hellou Pablo"
? oDict:Pablo
for n := 1 to MYLOOP
? n
for nn := 1 to 1000
_HDICT_SETPROP(hh, n , cPrintf( "Hellou %u",n) )
next
next
? oDict:GetProp(167)
? oDict:Richard
oDict:Destroy()
? "Seconds:" , Seconds() - nSeconds
inkey(0)
return NIL
// ---------------------------------------------------------------------------
/*
oDict : Pepito := "Hellou Pepito"
oDict : Menganito := { 1,2,3,4,5}
oDict : SetProp( "Joseh" , "Hellou Joseh" )
? oDict : Joseh // Hellou Joseh
? oDict : GetProp( "Joseh" )
*/
//use express++
#define cST aApp[01]
#define cCodCli aApp[02]
#define cPrestamo aApp[03]
#define cPrestamoACambiar aApp[04]
#define cMoneda aApp[05]
#define cMonto aApp[06]
#define cTasa aApp[07]
#define cInteres aApp[08]

//use class THDict
oApp := THDict():New()
oApp:cST
oApp:cCodCli
oApp:cPrestamo
oApp:cPrestamoACambiar
oApp:cMoneda
oApp:cMonto

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: OT4XB - HASHTABLE

#3 Post by patito »

Hi

manual of ot4xb, see page 76 and tells you how to use this function.

Best Regard
Héctor
Attachments
ot4xb-manual.rar
(1.26 MiB) Downloaded 754 times

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: OT4XB - HASHTABLE

#4 Post by Eugene Lutsenko »

What is the General purpose of OT4XB-HASHTABLE? What are the benefits?

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: OT4XB - HASHTABLE

#5 Post by patito »

Hi Eugene

Here in this url https://en.wikipedia.org/wiki/Hash_table
there's a description of what is a hash table

In computing, a hash table (hash map) is a data structure that implements an associative array abstract data type, a structure that can map keys to values.
A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found.
hash table is used in many languages, java, harbour, csharp, etc.
From the previous answer, download the manual for yourself and examples , and read page 76

Best Regard
Héctor Pezoa

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: OT4XB - HASHTABLE

#6 Post by Eugene Lutsenko »

Thank you very much, Héctor! And can they be used to handle CSV files, roughly like a database (dbf) with an index?

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: OT4XB - HASHTABLE

#7 Post by Auge_Ohr »

hi

when store a Password you store HASH instead of plain Text.
when have a HASH you can compare with other HASH but you can't get Original Value back.
greetings by OHR
Jimmy

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: OT4XB - HASHTABLE

#8 Post by patito »

Hi Eugene


Attached example using dbf and hash
You can make many combinations, even using xsd file, XML, etc etc etc etc.

Best regard
Héctor
Attachments
hashcont.rar
(147.99 KiB) Downloaded 756 times

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: OT4XB - HASHTABLE

#9 Post by patito »

Hi Jimmy

We're not talking about the openssl hash.
If you want to use this type of hash, ot4xb, you have
the following function (see manual use of cryptography in xbwin )

*1 = SHA1 2 = SHA256 3 = SHA384 4 = SHA512 (default hash type) - 512 bit Digest
FUNCTION fSha( _chain)
RETURN OT4XB_HASH():SHA256(_chain, 0)

But we're talking about hash table (htdic , expando class)
You do the following
oDict : SetProp( "Joseh" , "Hellou Joseh" )
? oDict : Joseh // Hellou Joseh
? oDict : GetProp( "Joseh" )

In ot4xb, you have hash and its derivative expando
You also have

If you save your name Jimmy, use (index and value )
then you can recover with find Jimmy

INLINE METHOD getNoIVar( k )
return ::get_prop(k)
//---------------------------------------
INLINE METHOD setNoIVar( k, v )
return ::set_prop(k,v)

Best Regard
Héctor

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: OT4XB - HASHTABLE

#10 Post by Auge_Ohr »

hi Héctor,
patito wrote:We're not talking about the openssl hash.
...
But we're talking about hash table (htdic , expando class)
ah ... have not used it yet.
it seem like Xbase++ v2.x DataObject :?:
greetings by OHR
Jimmy

Post Reply