コード例 #1
0
 def __add_to_bucket(self, bucket: LinkedList, item: tuple) -> None:
     if not self.__bucket_contains(bucket, item):
         bucket.append(item)
     else:
         current = bucket.get_head()
         while current:
             if current.value[0] == item[0]:
                 bucket.remove_value(current.value)
             current = current.next
         bucket.append(item)
コード例 #2
0
from singly_linked_list.singly_linked_list import LinkedList

linked_list = LinkedList(1)
linked_list.append(2)
linked_list.append(3)
linked_list.append(4)
linked_list.append(5)
linked_list.append_left(6)
linked_list.insert(3, 7)
linked_list.insert(0, 10)

print(linked_list)
linked_list.remove_at_index(linked_list.size() - 1)
print(linked_list)
linked_list.remove_value(3)
print(linked_list)
linked_list.reverse()
print(linked_list)
print(linked_list.pop())
print(linked_list)
print(linked_list.pop_left())
print(linked_list)