add more code to memoryManager
This commit is contained in:
parent
a954b4d9bc
commit
07c1e7f919
@ -12,26 +12,55 @@ class inputManager():
|
||||
self.listStorage = {}
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def addValueList(self, name, value):
|
||||
def addValueToFirstIndex(self, name, value):
|
||||
pass
|
||||
def addIndexList(self, name, maxLength = None, currList = [], currIndex = 0):
|
||||
self.listStorage[name] = {'list': currList, 'index': currIndex, 'maxLength': maxLength}
|
||||
def getNextIndexListElement(self, name):
|
||||
pass
|
||||
def getPrefIndexListElement(self, name):
|
||||
pass
|
||||
def getFirstIndexListElement(self, name):
|
||||
pass
|
||||
def getLastIndexListElement(self, name):
|
||||
pass
|
||||
def getNextIndex(self, name):
|
||||
if self.isIndexListEmpty(name):
|
||||
self.listStorage[name]['index'] = -1
|
||||
return False
|
||||
self.listStorage[name]['index'] += 1
|
||||
if self.listStorage[name]['index'] > len(self.listStorage[name]['list']) -1:
|
||||
self.listStorage[name]['index'] = 0
|
||||
return True
|
||||
def setPrefIndex(self, name):
|
||||
if self.isIndexListEmpty(name):
|
||||
self.listStorage[name]['index'] = -1
|
||||
return False
|
||||
def setFirstIndex(self, name):
|
||||
if self.isIndexListEmpty(name):
|
||||
self.listStorage[name]['index'] = -1
|
||||
return False
|
||||
self.listStorage[name]['index'] = 0
|
||||
return True
|
||||
def setLastIndex(self, name):
|
||||
if self.isIndexListEmpty(name):
|
||||
self.listStorage[name]['index'] = -1
|
||||
return False
|
||||
self.listStorage[name]['index'] = self.listStorage[name]['list'] -1
|
||||
return True
|
||||
def clearCurrentIndexList(self, name):
|
||||
self.listStorage[name]['index'] = []
|
||||
self.listStorage[name]['index'] = -1
|
||||
def getCurrentIndex(self,name):
|
||||
if self.isIndexListEmpty(name):
|
||||
self.listStorage[name]['index'] = -1
|
||||
return False
|
||||
try:
|
||||
return self.listStorage[name]['list']['index']
|
||||
return self.listStorage[name]['index']
|
||||
except:
|
||||
retrun 0
|
||||
retrun -1
|
||||
def isIndexListEmpty(self, name):
|
||||
return len(self.listStorage[name]['list']) == 0
|
||||
def getIndexListElement(self, name):
|
||||
if self.isIndexListEmpty(name):
|
||||
self.listStorage[name]['index'] = -1
|
||||
return False
|
||||
currIndex = self.getCurrentIndex(name)
|
||||
if currIndex == -1:
|
||||
return None
|
||||
try:
|
||||
return self.listStorage[name]['list'][currIndex]
|
||||
except:
|
||||
return []
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user