b311480e |
1 | -- Created on: 1993-01-07 |
2 | -- Created by: Remi LEQUETTE |
3 | -- Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
7 | -- |
d5f74e42 |
8 | -- This library is free software; you can redistribute it and/or modify it under |
9 | -- the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | -- by the Free Software Foundation, with special exception defined in the file |
11 | -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | -- distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | generic class MapHasher from TCollection (Key as any) |
18 | |
19 | ---Purpose: A hasher on the keys of a map instantiated from the |
20 | -- Collections component. |
21 | -- A hasher provides two functions: |
22 | -- - The hashing function (HashCode) transforms a key |
23 | -- into a bucket index in the map. The number of values |
24 | -- that can be computed by the hashing function is equal |
25 | -- to the number of buckets in the map. |
26 | -- - IsEqual is the equality test between two keys. |
27 | -- Hashers are used as parameters in generic maps |
28 | -- provided by the Collections component. |
29 | -- MapHasher is a generic class which depends on the type |
30 | -- of keys, provided that Key is a type from the Standard |
31 | -- package. In such cases MapHasher may be directly |
32 | -- instantiated with Key. Note that the package TColStd |
33 | -- provides some of these instantiations. |
34 | -- But if Key is not a type from the Standard package you |
35 | -- must consider MapHasher as a template and build a class |
36 | -- which includes its functions, in order to use it as a hasher |
37 | -- in a map instantiated from the Collections component. |
38 | -- Note that TCollection_AsciiString and |
39 | -- TCollection_ExtendedString classes correspond to |
40 | -- these specifications, in consequence they may be used as |
41 | -- hashers: when Key is one of these two types you may just |
42 | -- define the hasher as the same type at the time of |
43 | -- instantiation of your map. |
44 | |
45 | is |
46 | HashCode(myclass; K : Key; Upper : Integer) returns Integer; |
47 | ---Level: Public |
48 | ---Purpose: Returns a HasCode value for the Key <K> in the |
49 | -- range 0..Upper. |
50 | -- Default ::HashCode(K,Upper) |
51 | |
52 | IsEqual(myclass; K1, K2 : Key) returns Boolean; |
53 | ---Level: Public |
54 | ---Purpose: Returns True when the two keys are the same. Two |
55 | -- same keys must have the same hashcode, the |
56 | -- contrary is not necessary. |
57 | -- Default K1 == K2 |
58 | |
59 | end MapHasher; |