91 | | * Refactor all the classes as mix-ins between two groups of classes: |
92 | | # one group of classes that know the type of each element (int, num, str, pmc, any), and |
93 | | # another group of classes that compute memory addresses for indexed elements, perform resizing (or not), and report number of elements. |
94 | | (These latter would if necessary target the roles listed above, but a single compromise implementation would also work. -- kurahaupo) |
| 91 | == Refactoring == |
| 92 | Refactor all the classes as mix-ins between two groups of classes: |
96 | | A general-purpose resizable array would need these attrs: |
97 | | * element_type (bit, int8, int16, int32, int64, int128, float32, float64, float128, string, pmc, any) |
98 | | * allocated_size |
99 | | * initialized_size |
100 | | * logical_size |
101 | | * index_offset (used to make shift and unshift operate efficiently, not to allow arbitrary base indexing) |
| 94 | * one group of classes that know the type of each element (int, num, str, pmc, any), and |
| 95 | * another group of classes that compute memory addresses for indexed elements, perform resizing (or not), and report number of elements. |
| 96 | |
| 97 | (These latter would if necessary target the roles listed above, but a single compromise implementation would also work. -- kurahaupo) |
| 98 | |
| 99 | A general-purpose resizable array would need these attrs: |
| 100 | * element_size (corresponding to int8, int16, int32, int64, int128, float32, float64, float128, string, pmc & any) |
| 101 | * allocated_size |
| 102 | * initialized_size |
| 103 | * logical_size |
| 104 | * index_offset (used to make shift and unshift operate efficiently, not to allow arbitrary base indexing) |
| 105 | |
| 106 | A general-purpose fixed-sized array would only need the element size and number of elements. |