Skip to content

Commit 94d061c

Browse files
committed
adding example
1 parent ce14a87 commit 94d061c

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

ArrayList.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,3 @@ def __setitem__(self, index, value):
5656

5757
def __delitem__(self, index):
5858
del self.items[index]
59-
2.23 KB
Binary file not shown.

example.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from ArrayList import ArrayList
2+
3+
# Create a new list
4+
list = ArrayList(10)
5+
6+
# Add items to the list
7+
list.insert(1)
8+
list.insert(2)
9+
list.insert(3)
10+
list.insert(4)
11+
list.insert(5)
12+
13+
# Print the list
14+
print(list)
15+
16+
# Remove an item from the list
17+
list.remove(3)
18+
19+
# Print the list
20+
print(list)
21+
22+
# Check if an item is in the list
23+
print(list.search(3))
24+
print(list.search(4))
25+
26+
# Get an item from the list
27+
print(list.get(2))
28+
29+
# Print the length of the list
30+
print(len(list))
31+
32+
# Print the list
33+
print(list)
34+
35+
# Iterate over the list
36+
for item in list:
37+
print("\t", item)

0 commit comments

Comments
 (0)