-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from MLB-LED-Scoreboard/dev
Release 6.2.0
- Loading branch information
Showing
12 changed files
with
205 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from collections import deque | ||
|
||
|
||
class CircularQueue: | ||
""" | ||
A circular queue that stores a fixed number of items. | ||
Unlike a traditional ring buffer, reading from the queue does not | ||
remove the item from the queue. This allows the queue to be used | ||
to buffer incoming live game data in such a way that the first update is | ||
"instant", and the subsequent updates are delayed until the buffer is full. | ||
""" | ||
|
||
def __init__(self, size): | ||
self.size = size | ||
self.queue = deque(maxlen=size) | ||
|
||
def push(self, data): | ||
self.queue.append(data) | ||
|
||
def peek(self): | ||
top = self.queue.popleft() | ||
self.queue.appendleft(top) | ||
return top | ||
|
||
def __len__(self): | ||
return len(self.queue) |
Oops, something went wrong.