gate: start reorder

Signed-off-by: Thomas Klaehn <thomas.klaehn@u-blox.com>
This commit is contained in:
Thomas Klaehn
2017-03-30 11:05:31 +02:00
parent 0870736845
commit c1012382f2
27 changed files with 69 additions and 154 deletions

View File

@@ -0,0 +1,24 @@
class DataBuffer(object):
def __init__(self, length):
self.__max = length
self.__data = []
def push(self, element):
if self.__max == 0:
return False
if len(self.__data) == self.__max:
_ = self.__data.pop(0)
self.__data.append(element)
return True
def average(self):
if len(self.__data) != self.__max:
return None
return sum(self.__data) / len(self.__data)
def length(self):
return len(self.__data)
def clear(self):
self.__data = []

View File