Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ring buffer
  • Loading branch information
nomadic4life committed Jul 26, 2019
commit 74bbf8a83707aea8f5852bc322a90c53219e38c2
17 changes: 9 additions & 8 deletions ring_buffer/ring_buffer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
class RingBuffer:
def __init__(self, capacity):
self.capacity = capacity
self.current = 0
self.storage = [None]*capacity
def __init__(self, capacity):
self.capacity = capacity
self.current = 0
self.storage = [None]*capacity

def append(self, item):
pass
def append(self, item):
self.storage[self.current] = item
self.current = (self.current+1) % self.capacity

def get(self):
pass
def get(self):
return [x for x in self.storage if x != None]