add more code to memoryManager

This commit is contained in:
Chrys 2017-10-29 01:59:13 +02:00
parent a954b4d9bc
commit 07c1e7f919

View File

@ -12,26 +12,55 @@ class inputManager():
self.listStorage = {} self.listStorage = {}
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
def addValueList(self, name, value): def addValueToFirstIndex(self, name, value):
pass pass
def addIndexList(self, name, maxLength = None, currList = [], currIndex = 0): def addIndexList(self, name, maxLength = None, currList = [], currIndex = 0):
self.listStorage[name] = {'list': currList, 'index': currIndex, 'maxLength': maxLength} self.listStorage[name] = {'list': currList, 'index': currIndex, 'maxLength': maxLength}
def getNextIndexListElement(self, name): def getNextIndex(self, name):
pass if self.isIndexListEmpty(name):
def getPrefIndexListElement(self, name): self.listStorage[name]['index'] = -1
pass return False
def getFirstIndexListElement(self, name): self.listStorage[name]['index'] += 1
pass if self.listStorage[name]['index'] > len(self.listStorage[name]['list']) -1:
def getLastIndexListElement(self, name): self.listStorage[name]['index'] = 0
pass 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): def getCurrentIndex(self,name):
if self.isIndexListEmpty(name):
self.listStorage[name]['index'] = -1
return False
try: try:
return self.listStorage[name]['list']['index'] return self.listStorage[name]['index']
except: except:
retrun 0 retrun -1
def isIndexListEmpty(self, name):
return len(self.listStorage[name]['list']) == 0
def getIndexListElement(self, name): def getIndexListElement(self, name):
if self.isIndexListEmpty(name):
self.listStorage[name]['index'] = -1
return False
currIndex = self.getCurrentIndex(name) currIndex = self.getCurrentIndex(name)
if currIndex == -1:
return None
try: try:
return self.listStorage[name]['list'][currIndex] return self.listStorage[name]['list'][currIndex]
except: except:
return [] return None