mirror of
https://github.com/jlengrand/Coding4Interviews.git
synced 2026-03-10 08:11:24 +00:00
Starts working on Linked List. Single linked lists implementation for now.
This commit is contained in:
17
04_linkedList/ll.py
Normal file
17
04_linkedList/ll.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
"""
|
||||||
|
Implementation of Linked Lists
|
||||||
|
|
||||||
|
@jlengrand
|
||||||
|
2013/12
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class SingleListItem():
|
||||||
|
"""
|
||||||
|
Item from a Single Linked List.
|
||||||
|
Contains only a previous next element, and a value
|
||||||
|
"""
|
||||||
|
def __init__(self, value, next):
|
||||||
|
self.value = value
|
||||||
|
self.next = next
|
||||||
|
|
||||||
21
04_linkedList/ll_test.py
Normal file
21
04_linkedList/ll_test.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"""
|
||||||
|
Unit Tests for the Linked Lists implementations
|
||||||
|
@jlengrand
|
||||||
|
2013/12
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ll import SingleListItem
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class test_single_linked_list_item(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_item(self):
|
||||||
|
|
||||||
|
a = 12
|
||||||
|
t = SingleListItem(12, None)
|
||||||
|
|
||||||
|
self.assertEqual(a, t.value)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user