Tableau compact de naturels stockés sur n bits. Plus de détails...
Fonctions membres publiques | |
| def | __init__ |
| Constucteur. | |
| def | __getitem__ |
| self[key] | |
| def | __len__ |
| Nombre d'éléments. | |
| def | __repr__ |
| Transforme en string. | |
| def | __setitem__ |
| self[key] = value | |
Attributs publics | |
| size | |
| Taille maximale des éléments (en binaire) du tableau. | |
| len | |
| Nombre d'éléments contenu dans le tableau. | |
| a | |
| Array d'éléments de 32 bits contenant les éléments du tableau. | |
Tableau compact de naturels stockés sur n bits.
Tableau compact de naturels stockés sur n bits.
Les éléments sont stockés de façon contiguë en mémoire.
Par ex.: les éléments d'un tableau de 5 éléments sur 7 bits
occupe 35 bits arrondi à 2*32 == 64 bits
Pre: n: 1 <= naturel <= 32
Définition à la ligne 31 du fichier cnat32array.py.
| def DSPython.cnat32array.Cnat32array.__init__ | ( | self, | |
| size, | |||
items = None |
|||
| ) |
Constucteur.
Renvoie un tableau compact de naturels stockés sur size bits.
Si items == None alors renvoie un tableau vide
Pre: size: 1 <= naturel <= 32
items: None
O() = ...
Définition à la ligne 40 du fichier cnat32array.py.
Références DSPython.natural_is().
| def DSPython.cnat32array.Cnat32array.__getitem__ | ( | self, | |
| key | |||
| ) |
self[key]
Renvoie l'élément d'indice key ou un tuple contenant les éléments de la tranche key. Lève une exception IndexError si le ou les indices n'existent pas Pre: key: entier ou tranche Result: naturel < 2**32 ou tuple de naturels < 2**32 O() = ...
Définition à la ligne 64 du fichier cnat32array.py.
Références DSPython.cnat32array.Cnat32array.a, DSPython.numbernone.divmod(), DSPython.cnat32array.Cnat32array.len, DSPython.natural_is(), et DSPython.cnat32array.Cnat32array.size.
| def DSPython.cnat32array.Cnat32array.__len__ | ( | self | ) |
Nombre d'éléments.
Renvoie le nombre d'éléments du tableau Result: naturel O() = 1
Définition à la ligne 100 du fichier cnat32array.py.
Références DSPython.cnat32array.Cnat32array.len.
| def DSPython.cnat32array.Cnat32array.__repr__ | ( | self | ) |
Transforme en string.
Si le tableau est vide alors renvoie 'Cnat32array()' sinon renvoie 'Cnat32array(size, [éléments])' Result: string quotée O() = ...
Définition à la ligne 110 du fichier cnat32array.py.
Références DSPython.cnat32array.Cnat32array.a, DSPython.cnat32array.Cnat32array.len, et DSPython.cnat32array.Cnat32array.size.
| def DSPython.cnat32array.Cnat32array.__setitem__ | ( | self, | |
| key, | |||
| value | |||
| ) |
self[key] = value
Modifie le ou les éléments d'indice key par value. Lève une exception IndexError si le ou les indices n'existent pas Pre: key: entier ou tranche O() = ...
Définition à la ligne 122 du fichier cnat32array.py.
Références DSPython.cnat32array.Cnat32array.a, DSPython.cnat32array.Cnat32array.len, DSPython.tnp1.main_test(), DSPython.natural_is(), et DSPython.cnat32array.Cnat32array.size.