Menu

[r7]: / SimpleList.py  Maximize  Restore  History

Download this file

72 lines (40 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from Translator import *
class SSSSimpleList(object):
def __init__(self, parentObject = None, test = ''):
self.items = []
self._parentObject = parentObject
def item(self, index):
item = self.items[index]
if (item):
return item
#// Throw error...
return False
def insertItem(self, item, index):
if (index >= 0):
if index == len(self.items): #// add to end...
self.items.append(item)
elif index == 0: #// add to beginning...
#array_unshift(self.items, item)
for i in xrange(len(self.items)):
item.insert(i, self.items[i])
else: #// insert into middle of items...
addLogMessage('(else) SSSSimpleList insertItem: index = ' + index)
start = self.items[0:index - len(self.items)]
end = self.items[index]
start.append(item)
self.items = start + end
return index
def appendItem(self, item):
self.insertItem(item, self.length)
def __call(self, method, args):
if (method == 'item'):
item = self.items[args[0]]
if (item):
return item
return False
def getLength(self):
count = len(self.items)
if (count):
return count
return 0
length = property(getLength)
MongoDB Logo MongoDB