Class DS_SEARCHABLE PreviousNext

note
description:

    "Data structures that can be searched"

library:    "Gobo Eiffel Structure Library"
author:     "Eric Bezault <ericb@gobosoft.com>"
copyright:  "Copyright (c) 1999-2001, Eric Bezault and others"
license:    "MIT License"
deferred class interface
DS_SEARCHABLE [G]
inherit
DS_CONTAINER [G]
feature {NONE} -- Initialization
make_default
        -- Create an empty container.
        -- (From DS_CONTAINER.)
    deferred
    ensure
        empty: is_empty
feature -- Access
equality_tester: DS_EQUALITY_TESTER [G]
        -- Equality tester;
        -- A void equality tester means that `='
        -- will be used as comparison criterion.
feature -- Measurement
count: INTEGER
        -- Number of items in container
        -- (From DS_CONTAINER.)
    deferred
occurrences (v: G): INTEGER
        -- Number of times v appears in container
        -- (Use equality_tester's comparison criterion
        -- if not void, use `=' criterion otherwise.)
    deferred
    ensure
        positive: Result >= 0
        has: has (v) implies Result >= 1
feature -- Status report
has (v: G): BOOLEAN
        -- Does container include v?
        -- (Use equality_tester's comparison criterion
        -- if not void, use `=' criterion otherwise.)
    deferred
    ensure
        not_empty: Result implies not is_empty
same_items (v, u: G): BOOLEAN
        -- Are v and u considered equal?
        -- (Use equality_tester's comparison criterion
        -- if not void, use `=' criterion otherwise.)
same_equality_tester (other: DS_SEARCHABLE [G]): BOOLEAN
        -- Does container use the same comparison
        -- criterion as other?
    require
        other_not_void: other /= Void
equality_tester_settable (a_tester: like equality_tester): BOOLEAN
        -- Can set_equality_tester be called with a_tester
        -- as argument in current state of container?
        -- (Default answer: True.)
is_empty: BOOLEAN
        -- Is container empty?
        -- (From DS_CONTAINER.)
feature -- Comparison
is_equal (other: like Current): BOOLEAN
        -- Is current container equal to other?
        -- (From GENERAL.)
    require
        other_not_void: other /= Void
    deferred
    ensure
        consistent: standard_is_equal (other) implies Result
        same_type: Result implies same_type (other)
        symmetric: Result implies other.is_equal (Current)
        same_count: Result implies count = other.count
feature -- Duplication
copy (other: like Current)
        -- Copy other to current container.
        -- (From GENERAL.)
    require
        other_not_void: other /= Void
        type_identity: same_type (other)
    deferred
    ensure
        is_equal: is_equal (other)
feature -- Setting
set_equality_tester (a_tester: like equality_tester)
        -- Set equality_tester to a_tester.
        -- A void equality tester means that `='
        -- will be used as comparison criterion.
    require
        equality_tester_settable: equality_tester_settable (a_tester)
    ensure
        equality_tester_set: equality_tester = a_tester
feature -- Removal
wipe_out
        -- Remove all items from container.
        -- (From DS_CONTAINER.)
    deferred
    ensure
        wiped_out: is_empty
invariant
positive_count: count >= 0
empty_definition: is_empty = (count = 0)
    -- (From DS_CONTAINER.)
end -- class DS_SEARCHABLE

Copyright © 1999-2001, Eric Bezault
mailto:
ericb@gobosoft.com
http:
//www.gobosoft.com
Last Updated: 31 March 2001

HomeTocPreviousNext