GNU
|
Liberty Eiffel
|
Automated Tests
|
Wiki
|
Savannah project
|
Debian packages
|
Documentation
>
libraries
>
ENUMERATE
+
Point of view
All features
ANY
All features
class ENUMERATE [V_]
Summary
top
Enumerate a traversable
Direct parents
Inherit list:
ZIP
Class invariant
top
items.count = keys.count
Overview
top
Creation features
{
ANY
}
make
(a_items:
TRAVERSABLE
[
ANY
])
Features
{
ANY
}
make
(a_items:
TRAVERSABLE
[
ANY
])
{
ANY
}
lower
:
INTEGER_32
Minimum index.
upper
:
INTEGER_32
Maximum index.
count
:
INTEGER_32
Number of available items in the hoard.
copy
(other: ENUMERATE [V_])
Update current object using fields of object attached to
other
, so as to yield equal objects.
has
(k: K_):
BOOLEAN
Is there a value currently associated with key
k
?
at
(k: K_): V_
Return the value associated to key
k
.
reference_at
(k: K_): V_
Return Void or the value associated with key
k
.
fast_has
(k: K_):
BOOLEAN
Is there a value currently associated with key
k
?
fast_at
(k: K_): V_
Return the value associated to key
k
using basic
=
for comparison.
fast_reference_at
(k: K_): V_
Same work as
reference_at
, but basic
=
is used for comparison.
item
(index:
INTEGER_32
): V_
Item at the corresponding index
i
.
key
(index:
INTEGER_32
): K_
new_iterator_on_items
: ITERATOR[V_]
new_iterator_on_keys
: ITERATOR[K_]
new_iterator
: ITERATOR[TUPLE 2[V_, K_]]
Other features:
{
ANY
}
internal_key
(k: K_): K_
Retrieve the internal key object which correspond to the existing entry
k
(the one memorized into the
Current
dictionary).
{
ANY
}
items
: TRAVERSABLE[V_]
An iterable of this map values Usually returns Current because
MAP
is
TRAVERSABLE
.
keys
: TRAVERSABLE[K_]
An iterable of this map keys
{}
index_of
(k: K_):
INTEGER_32
fast_index_of
(k: K_):
INTEGER_32
Counting:
{
ANY
}
is_empty
:
BOOLEAN
Is it empty?
Basic access:
{
ANY
}
infix "@"
(k: K_): V_
The infix notation which is actually a synonym for
at
.
Looking and searching some value:
{
ANY
}
occurrences
(v: V_):
INTEGER_32
Number of occurrences using
is_equal
for comparison.
fast_occurrences
(v: V_):
INTEGER_32
Number of occurrences using basic
=
for comparison.
key_at
(v: V_): K_
Retrieve the key used for value
v
using
is_equal
for comparison.
fast_key_at
(v: V_): K_
Retrieve the key used for value
v
using
=
for comparison.
To provide iterating facilities:
{
ANY
}
first
: V_
The very
first
item.
last
: V_
The
last
item.
key_map_in
(buffer: COLLECTION[K_])
Append in
buffer
, all available keys (this may be useful to speed up the traversal).
item_map_in
(buffer: COLLECTION[V_])
Append in
buffer
, all available items (this may be useful to speed up the traversal).
{
ANY
}
fast_is_equal
(other: ENUMERATE [V_]):
BOOLEAN
Do both dictionaries have the same set of associations?
is_equal
(other: ENUMERATE [V_]):
BOOLEAN
Do both dictionaries have the same set of associations?
is_equal_map
(other: ENUMERATE [V_]):
BOOLEAN
Do both collections have the same
lower
,
upper
, and items?
Display support:
{
ANY
}
out_in_tagged_out_memory
Append terse printable representation of current object in
tagged_out_memory
.
Agents based features:
{
ANY
}
for_each
(action:
PROCEDURE
[
TUPLE
[TUPLE 2[V_, K_]]])
Apply
action
to every [V_, K_] associations of
Current
.
do_all
(action:
ROUTINE
[
TUPLE
[TUPLE 2[V_, K_]]])
Apply
action
to every [V_, K_] associations of
Current
.
for_all
(test:
FUNCTION
[
TUPLE
[TUPLE 2[V_, K_]]]):
BOOLEAN
Do all [V_, K_] associations satisfy
test
?
exists
(test:
FUNCTION
[
TUPLE
[TUPLE 2[V_, K_]]]):
BOOLEAN
Does at least one [V_, K_] association satisfy
test
?
aggregate
(action:
FUNCTION
[
TUPLE
[TUPLE 3[V_, V_, K_], V_]], initial: V_): V_
Aggregate all the elements starting from the initial value.
{}
keys_memory
: DICTIONARY_KEY_TRAVERSER[V_, K_]
{}
_inline_agent43
(v: V_, k: K_)
{
ANY
}
enumerate
: ENUMERATE[E_]
Other features:
{
ANY
}
get_new_iterator
: ITERATOR[E_]
{
ANY
}
generation
:
INTEGER_32
{}
next_generation
{}
_inline_agent1
(a:
ROUTINE
[
TUPLE
[TUPLE 1[E_]]], e: E_)
Indexing:
{
ANY
}
valid_index
(i:
INTEGER_32
):
BOOLEAN
True when
i
is valid (i.e., inside actual bounds).
{
ANY
}
test
(e1: E_, e2: E_):
BOOLEAN
In order to avoid run-time type errors, feature
safe_equal
calls
is_equal
only when
e1
and
e2
have exactly the same dynamic type.
safe_equal
(e1: E_, e2: E_):
BOOLEAN
In order to avoid run-time type errors, feature
safe_equal
calls
is_equal
only when
e1
and
e2
have exactly the same dynamic type.
make
(a_items:
TRAVERSABLE
[
ANY
])
effective procedure
{
ANY
}
top
ensure
items
= a_items
lower
:
INTEGER_32
is 0
constant attribute
{
ANY
}
top
Minimum index.
See also
upper
,
valid_index
,
item
.
upper
:
INTEGER_32
effective function
{
ANY
}
top
Maximum index.
See also
lower
,
valid_index
,
item
.
ensure
count = Result - lower + 1
count
:
INTEGER_32
effective function
{
ANY
}
top
Number of available items in the hoard.
See also
is_empty
ensure
Result >= 0
copy
(other: ENUMERATE [V_])
effective procedure
{
ANY
}
top
Update current object using fields of object attached to
other
, so as to yield equal objects.
Note: you can't copy object from a different dynamic type.
require
not immutable
same_dynamic_type(other)
not immutable
same_dynamic_type(other)
not immutable
same_dynamic_type(other)
ensure
is_equal(other)
has
(k: K_):
BOOLEAN
effective function
{
ANY
}
top
Is there a value currently associated with key
k
?
See also
fast_has
,
at
.
require
k /= Void
at
(k: K_): V_
effective function
{
ANY
}
top
Return the value associated to key
k
.
See also
fast_at
,
reference_at
,
has
.
require
has(k)
reference_at
(k: K_): V_
effective function
{
ANY
}
top
Return Void or the value associated with key
k
.
Actually, this feature is useful only when the type of values (the type V_) is a reference type, to avoid using
has
just followed by
at
to get the corresponding value with the very best performances.
See also
fast_reference_at
,
at
,
has
.
require
k /= Void
values_are_not_expanded:
Result = Void
ensure
has(k) implies Result = at(k)
fast_has
(k: K_):
BOOLEAN
effective function
{
ANY
}
top
Is there a value currently associated with key
k
?
Using basic
=
for comparison.
See also
has
,
at
,
fast_at
.
require
k /= Void
fast_at
(k: K_): V_
effective function
{
ANY
}
top
Return the value associated to key
k
using basic
=
for comparison.
See also
at
,
reference_at
,
fast_reference_at
.
require
fast_has(k)
fast_reference_at
(k: K_): V_
effective function
{
ANY
}
top
Same work as
reference_at
, but basic
=
is used for comparison.
See also
reference_at
,
at
,
has
.
require
k /= Void
values_are_reference:
Result = Void
ensure
fast_has(k) implies Result = fast_at(k)
item
(index:
INTEGER_32
): V_
effective function
{
ANY
}
top
Item at the corresponding index
i
.
See also
lower
,
upper
,
valid_index
.
require
valid_index(index)
ensure
Result = at(key(index))
key
(index:
INTEGER_32
): K_
effective function
{
ANY
}
top
require
valid_index(index)
ensure
at(Result) = item(index)
new_iterator_on_items
: ITERATOR[V_]
effective function
{
ANY
}
top
ensure
Result /= Void
Result /= Void
Result.generation = generation
new_iterator_on_keys
: ITERATOR[K_]
effective function
{
ANY
}
top
ensure
Result /= Void
new_iterator
: ITERATOR[TUPLE 2[V_, K_]]
effective function
{
ANY
}
top
ensure
Result /= Void
internal_key
(k: K_): K_
effective function
{
ANY
}
top
Retrieve the internal key object which correspond to the existing entry
k
(the one memorized into the
Current
dictionary).
See also
has
,
fast_has
.
require
has(k)
ensure
Result.is_equal(k)
items
: TRAVERSABLE[V_]
writable attribute
{
ANY
}
top
An iterable of this map values Usually returns Current because
MAP
is
TRAVERSABLE
.
ensure
Result.count = count
keys
: TRAVERSABLE[K_]
writable attribute
{
ANY
}
top
An iterable of this map keys
ensure
Result.count = count
index_of
(k: K_):
INTEGER_32
effective function
{}
top
fast_index_of
(k: K_):
INTEGER_32
effective function
{}
top
is_empty
:
BOOLEAN
effective function
{
ANY
}
top
Is it empty?
ensure
definition:
Result = count = 0
infix "@"
(k: K_): V_
frozen
effective function
{
ANY
}
top
The infix notation which is actually a synonym for
at
.
require
has
(k)
ensure
definition:
Result =
at
(k)
occurrences
(v: V_):
INTEGER_32
effective function
{
ANY
}
top
Number of occurrences using
is_equal
for comparison.
See also
fast_occurrences
,
fast_has
,
has
.
ensure
Result >= 0
fast_occurrences
(v: V_):
INTEGER_32
effective function
{
ANY
}
top
Number of occurrences using basic
=
for comparison.
See also
occurrences
,
fast_has
,
has
.
ensure
Result >= 0
key_at
(v: V_): K_
effective function
{
ANY
}
top
Retrieve the key used for value
v
using
is_equal
for comparison.
See also
fast_key_at
,
at
.
require
occurrences
(v) = 1
ensure
(create {
SAFE_EQUAL
}).test(
at
(Result), v)
fast_key_at
(v: V_): K_
effective function
{
ANY
}
top
Retrieve the key used for value
v
using
=
for comparison.
See also
key_at
,
at
.
require
fast_occurrences
(v) = 1
ensure
at
(Result) = v
first
: V_
effective function
{
ANY
}
top
The very
first
item.
See also
last
,
item
.
require
not is_empty
ensure
definition:
Result = item(lower)
last
: V_
effective function
{
ANY
}
top
The
last
item.
See also
first
,
item
.
require
not is_empty
ensure
definition:
Result = item(upper)
key_map_in
(buffer: COLLECTION[K_])
effective procedure
{
ANY
}
top
Append in
buffer
, all available keys (this may be useful to speed up the traversal).
See also
item_map_in
.
require
buffer /= Void
ensure
buffer.count =
count
+ old buffer.count
item_map_in
(buffer: COLLECTION[V_])
effective procedure
{
ANY
}
top
Append in
buffer
, all available items (this may be useful to speed up the traversal).
See also
key_map_in
.
require
buffer /= Void
ensure
buffer.count =
count
+ old buffer.count
fast_is_equal
(other: ENUMERATE [V_]):
BOOLEAN
effective function
{
ANY
}
top
Do both dictionaries have the same set of associations?
Keys are compared with
is_equal
and values are compared with the basic = operator.
See also
is_equal
.
ensure
Result implies
count
= other.
count
is_equal
(other: ENUMERATE [V_]):
BOOLEAN
effective function
{
ANY
}
top
Do both dictionaries have the same set of associations?
Both keys and values are compared with
is_equal
.
See also
fast_is_equal
.
require
other /= Void
other /= Void
ensure
commutative:
generating_type = other.generating_type implies Result = other.is_equal(Current)
is_equal_map
(other: ENUMERATE [V_]):
BOOLEAN
effective function
{
ANY
}
top
Do both collections have the same
lower
,
upper
, and items?
This feature is obsolete:
Use `is_equal' instead.
out_in_tagged_out_memory
effective procedure
{
ANY
}
top
Append terse printable representation of current object in
tagged_out_memory
.
require
locked:
tagged_out_locked
locked:
tagged_out_locked
ensure
still_locked:
tagged_out_locked
not_cleared:
tagged_out_memory.count >= old tagged_out_memory.count
append_only:
old tagged_out_memory.twin.is_equal(tagged_out_memory.substring(1, old tagged_out_memory.count))
for_each
(action:
PROCEDURE
[
TUPLE
[TUPLE 2[V_, K_]]])
effective procedure
{
ANY
}
top
Apply
action
to every [V_, K_] associations of
Current
.
See also
for_all
,
exist
.
require
action /= Void
do_all
(action:
ROUTINE
[
TUPLE
[TUPLE 2[V_, K_]]])
frozen
effective procedure
{
ANY
}
top
Apply
action
to every [V_, K_] associations of
Current
.
This feature is obsolete:
This feature is not secure because it accepts a FUNCTION, the result of which is lost. Plese use `for_each` instead.
for_all
(test:
FUNCTION
[
TUPLE
[TUPLE 2[V_, K_]]]):
BOOLEAN
effective function
{
ANY
}
top
Do all [V_, K_] associations satisfy
test
?
See also
for_each
,
exist
.
require
test /= Void
exists
(test:
FUNCTION
[
TUPLE
[TUPLE 2[V_, K_]]]):
BOOLEAN
effective function
{
ANY
}
top
Does at least one [V_, K_] association satisfy
test
?
See also
for_all
,
for_each
.
require
test /= Void
aggregate
(action:
FUNCTION
[
TUPLE
[TUPLE 3[V_, V_, K_], V_]], initial: V_): V_
effective function
{
ANY
}
top
Aggregate all the elements starting from the initial value.
See also
for_each
,
for_all
,
exists
.
require
action /= Void
keys_memory
: DICTIONARY_KEY_TRAVERSER[V_, K_]
writable attribute
{}
top
_inline_agent43
(v: V_, k: K_)
frozen
effective procedure
{}
top
enumerate
: ENUMERATE[E_]
effective function
{
ANY
}
top
get_new_iterator
: ITERATOR[E_]
frozen
effective function
{
ANY
}
top
This feature is obsolete:
Use `new_iterator' instead. This historical SmartEiffel feature is badly named.
generation
:
INTEGER_32
writable attribute
{
ANY
}
top
next_generation
effective procedure
{}
top
ensure
generation
> old
generation
_inline_agent1
(a:
ROUTINE
[
TUPLE
[TUPLE 1[E_]]], e: E_)
frozen
effective procedure
{}
top
valid_index
(i:
INTEGER_32
):
BOOLEAN
effective function
{
ANY
}
top
True when
i
is valid (i.e., inside actual bounds).
See also
lower
,
upper
,
item
.
ensure
definition:
Result =
lower
<= i and i <=
upper
test
(e1: E_, e2: E_):
BOOLEAN
effective function
{
ANY
}
top
In order to avoid run-time type errors, feature
safe_equal
calls
is_equal
only when
e1
and
e2
have exactly the same dynamic type.
safe_equal
(e1: E_, e2: E_):
BOOLEAN
effective function
{
ANY
}
top
In order to avoid run-time type errors, feature
safe_equal
calls
is_equal
only when
e1
and
e2
have exactly the same dynamic type.