Skip to content

Instantly share code, notes, and snippets.

@mattstibbs
Created October 29, 2017 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattstibbs/68f095e4cac509646768c4a7f5dcd811 to your computer and use it in GitHub Desktop.
Save mattstibbs/68f095e4cac509646768c4a7f5dcd811 to your computer and use it in GitHub Desktop.
RecentyUsedList - code
class RecentlyUsedList():
def __init__(self):
self.list_of_items = []
def __len__(self):
return len(self.list_of_items)
def insert(self, item):
if item in self.list_of_items:
self.list_of_items.remove(item)
self.list_of_items.insert(0, item)
def __getitem__(self, index):
return self.list_of_items[index]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment