MAINSAIL Language Manual, Section 37.2

previous   next   top   complete contents   complete index   framed top   this page unframed


37.2. $hash

Figure 37–2. $hash
INTEGER
PROCEDURE   $hash       (STRING key;
                         
INTEGER buckets);

$hash is a general-purpose hash function that generates an INTEGER in the range 0 to buckets - 1 based on key (the effect is undefined if buckets is less than one). The algorithm differs from that used by HSHMOD (see Section 37.5), and is subject to change from release to release of MAINSAIL.

$hash is not a MODULE interface PROCEDURE, so calls to it may be usefully prefixed with INLINE or $ALWAYSINLINE; this may be advisable when fast hashing is important. The code for $hash is not completely trivial, however, so INLINE calls to it should not be made too many times per MODULE, or the generated code will take up a lot of space.


previous   next   top   complete contents   complete index   framed top   this page unframed

MAINSAIL Language Manual, Section 37.2