/src/lib/abilities/hashable.e
Specman e | 52 lines | 17 code | 4 blank | 31 comment | 0 complexity | 52d682e9acc82edd2d884e69dcf16a6b MD5 | raw file
1-- This file is part of a Liberty Eiffel library. 2-- See the full copyright at the end. 3-- 4deferred class HASHABLE 5 -- 6 -- Ancestor class for all hashable objects. 7 -- 8 -- For example, the `hash_code' is needed for HASHED_DICTIONARY and for HASHED_SET. Thus, most standard 9 -- objects are HASHABLE (STRING, REAL, INTEGER_8, INTEGER_16, INTEGER_32, INTEGER_64, POINTER, NUMBER, 10 -- MUTABLE_BIG_INTEGER, and so forth). 11 -- 12 13insert 14 ANY 15 redefine is_equal 16 end 17 18feature {ANY} 19 hash_code: INTEGER 20 -- The hash-code value of `Current'. 21 deferred 22 ensure 23 good_hash_value: Result >= 0 24 end 25 26 is_equal (other: like Current): BOOLEAN 27 deferred 28 ensure then 29 Result implies hash_code = other.hash_code 30 end 31 32end -- class HASHABLE 33-- 34-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file. 35-- 36-- Permission is hereby granted, free of charge, to any person obtaining a copy 37-- of this software and associated documentation files (the "Software"), to deal 38-- in the Software without restriction, including without limitation the rights 39-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 40-- copies of the Software, and to permit persons to whom the Software is 41-- furnished to do so, subject to the following conditions: 42-- 43-- The above copyright notice and this permission notice shall be included in 44-- all copies or substantial portions of the Software. 45-- 46-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 47-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 49-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 52-- THE SOFTWARE.