| Home | Trees | Indices | Help |
|---|
|
|
object --+
|
structure.sage_object.SageObject --+
|
CombinatorialObject
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from |
|||
|
|||
|
Inherited from |
|||
|
|||
CombinatorialObject provides a thin wrapper around a list.
The main differences are that __setitem__ is disabled so that
CombinatorialObjects are shallowly immutable, and the intention
is that they are semantically immutable.
Because of this, CombinatorialObjects provide a __hash__
function which computes the hash of the string representation
of a list and the hash of its parent's class. Thus, each
CombinatorialObject should have a unique string representation.
INPUT:
l -- a list
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: c == loads(dumps(c))
True
sage: c._list
[1, 2, 3]
sage: c._hash is None
True
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: str(c)
'[1, 2, 3]'
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: c.__repr__()
'[1, 2, 3]'
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: d = CombinatorialObject([2,3,4])
sage: c == [1,2,3]
True
sage: c == [2,3,4]
False
sage: c == d
False
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: d = CombinatorialObject([2,3,4])
sage: c < d
True
sage: c < [2,3,4]
True
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: d = CombinatorialObject([2,3,4])
sage: c <= c
True
sage: c <= d
True
sage: c <= [1,2,3]
True
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: d = CombinatorialObject([2,3,4])
sage: c > c
False
sage: c > d
False
sage: c > [1,2,3]
False
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: d = CombinatorialObject([2,3,4])
sage: c >= c
True
sage: c >= d
False
sage: c >= [1,2,3]
True
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: d = CombinatorialObject([2,3,4])
sage: c != c
False
sage: c != d
True
sage: c != [1,2,3]
False
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: c + [4]
[1, 2, 3, 4]
sage: type(_)
<type 'list'>
|
Computes the hash of self by computing the hash of the
string representation of self._list. The hash is cached
and stored in self._hash.
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: c._hash is None
True
sage: hash(c) #random
1335416675971793195
sage: c._hash #random
1335416675971793195
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: len(c)
3
sage: c.__len__()
3
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: c[0]
1
sage: c[1:]
[2, 3]
sage: type(_)
<type 'list'>
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: list(iter(c))
[1, 2, 3]
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: 1 in c
True
sage: 5 in c
False
|
EXAMPLES:
sage: c = CombinatorialObject([1,2,3])
sage: c.index(1)
0
sage: c.index(3)
2
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Thu Jul 17 04:23:32 2008 | http://epydoc.sourceforge.net |