This commit is contained in:
Miroslav Stampar
2024-08-05 17:47:30 +02:00
parent 238ca3ccd8
commit 8b55644631
3 changed files with 10 additions and 5 deletions

View File

@@ -65,6 +65,8 @@ class BigArray(list):
>>> _ = _ + [1]
>>> _[-1]
1
>>> len([_ for _ in BigArray(xrange(100000))])
100000
"""
def __init__(self, items=None):
@@ -198,7 +200,10 @@ class BigArray(list):
def __iter__(self):
for i in xrange(len(self)):
yield self[i]
try:
yield self[i]
except IndexError:
break
def __len__(self):
return len(self.chunks[-1]) if len(self.chunks) == 1 else (len(self.chunks) - 1) * self.chunk_length + len(self.chunks[-1])