(Definition with initialization by copying) Definition with initialization by copying is possible for every LEDA type. It initializes the defined variable with a copy of the argument of the definition. The next rule states precisely what a copy of a value is.
(Copy of a value) Assignment operator and copy constructor of LEDA types create copies of values. This rule defines recursively what is meant by the notion ``copy of a value''.
A copy of a value of a primitive type (built-in type, pointer type, item type) is a bitwise copy of this value.
A value x
of a
simple-structured type is a set or a sequence of values,
respectively.
A copy of x
is a componentwise
copy of all constituent values of this set or this
sequence, respectively.
A value x
of an item-based,
structured type is a structured collection of
values.
A copy of x
is a collection of
new values, each one of which is the copy of a value of
x
, the original . The
combinatorical structure imposed to the new values is
isomorphic to the structure of x
, the
original.
(Equality and identity) This rule defines when two
objects x
and y
are
considered as equal and identical, respectively.
For objects x
and
y
of a dependent item type, the
equality predicate x==y
means
equality between the values of these objects.
For objects x
and
y
of an independent item type
T
, the equality predicate
x==y
is defined individually for each
such item type. In the majority of cases it means
equality between the values of x
and
y
, but this is not guaranteed for
every type.
Provided that the identity predicate
bool identical(const T&, const T&);
is defined on type T
, it means equality between the values of these objects.
For objects x
and
y
of a structured type the equality
predicate x==y
means equality
between the values of these objects.
(Illegal access via an item) It is illegal to access a
container which has been destroyed via an item, or to access
a container via the item nil
.
(Initialization of attributes of an independent item type) The attributes of an independent item type are always defined. In particular, a definition with default initialization initializes all attributes. Such a type may specify the initial values, but it need not.
(Specification of the structure to be traversed in forall
-macros)
The argument in a forall
-macro which specifies the
structure to be traversed should not be a function call which
returns this structure, but rather an object by itself which
represents this structure.
(Modification of objects of an item-based container type while iterating over them)
An iteration over an object x
of an item-based
container type must not add new elements to x
. It
may delete the element which the iterator item points to, but no other
element. The values of the elements may be modified without any
restrictions.
(Requirements for type parameters)
Every type parameter T
must implement the following functions:
a default constructor | T::T() |
a copy constructor | T::T(const T&) |
an assigment operator | T& T::operator = (const T&) |
an input operator | istream& operator >> (istream&, T&) |
an output operator | ostream& operator << (ostream&, const T&) |
(Requirements for linearly ordered types)
In addition to the Requirements for type parameters a linearly ordered type must implement
a compare function | int compare(const T&, const T&) |
Here, for the function compare()
the following must hold:
It must be put in the namespace leda
.
It must realize a linear order on T
.
If y
is the copy of a value x
of type T
, then
compare(x,y) == 0
must hold.
(Requirements for hashed types) In addition to the Requirements for type parameters a hashed type must implement
a hash function | int Hash(const T&) |
an equality operator | bool operator == (const T&, const T&) |
Here, for the function Hash()
the following must
hold:
It must be put in the namespace leda
.
For all objects x
and
y
of type T
: If
x == y
holds, then so does Hash(x) == Hash(y)
.
For the equality operator
operator==()
the following must hold:
It defines an equivalence relation on
T
.
If y
is a copy of a value
x
of type T
, then
x == y
must hold.
(Requests for numerical types)
In addition to the
Requirements for type parameters
a numerical type must offer the arithmetical operators
operator+()
,
operator-()
, and operator*()
,
as well as the comparison operators
operator<()
,
operator<=()
,
operator>()
,
operator>=()
,
operator==()
, and
operator!=()
.