Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 67b3725

Browse files
authored
Merge pull request #2 from bobocode-projects/GP-26-MergeLinkedListIntoNewRepo
GP-26 Add LinkedList
2 parents 9cf7678 + 19a5440 commit 67b3725

File tree

3 files changed

+452
-0
lines changed

3 files changed

+452
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package com.bobocode.LinkedList;
2+
3+
/**
4+
* {@link LinkedList} is a list implementation that is based on singly linked generic nodes. A node is implemented as
5+
* inner static class {@link Node<T>}. In order to keep track on nodes, {@link LinkedList} keeps a reference to a head node.
6+
*
7+
* @param <T> generic type parameter
8+
*/
9+
public class LinkedList<T> implements List<T> {
10+
11+
/**
12+
* This method creates a list of provided elements
13+
*
14+
* @param elements elements to add
15+
* @param <T> generic type
16+
* @return a new list of elements the were passed as method parameters
17+
*/
18+
public static <T> List<T> of(T... elements) {
19+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
20+
}
21+
22+
/**
23+
* Adds an element to the end of the list
24+
*
25+
* @param element element to add
26+
*/
27+
@Override
28+
public void add(T element) {
29+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
30+
}
31+
32+
/**
33+
* Adds a new element to the specific position in the list. In case provided index in out of the list bounds it
34+
* throws {@link IndexOutOfBoundsException}
35+
*
36+
* @param index an index of new element
37+
* @param element element to add
38+
*/
39+
@Override
40+
public void add(int index, T element) {
41+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
42+
}
43+
44+
/**
45+
* Changes the value of an list element at specific position. In case provided index in out of the list bounds it
46+
* throws {@link IndexOutOfBoundsException}
47+
*
48+
* @param index an position of element to change
49+
* @param element a new element value
50+
*/
51+
@Override
52+
public void set(int index, T element) {
53+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
54+
}
55+
56+
/**
57+
* Retrieves an elements by its position index. In case provided index in out of the list bounds it
58+
* throws {@link IndexOutOfBoundsException}
59+
*
60+
* @param index element index
61+
* @return an element value
62+
*/
63+
@Override
64+
public T get(int index) {
65+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
66+
}
67+
68+
/**
69+
* Removes an elements by its position index. In case provided index in out of the list bounds it
70+
* throws {@link IndexOutOfBoundsException}
71+
*
72+
* @param index element index
73+
*/
74+
@Override
75+
public void remove(int index) {
76+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
77+
}
78+
79+
80+
/**
81+
* Checks if a specific exists in he list
82+
*
83+
* @return {@code true} if element exist, {@code false} otherwise
84+
*/
85+
@Override
86+
public boolean contains(T element) {
87+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
88+
}
89+
90+
/**
91+
* Checks if a list is empty
92+
*
93+
* @return {@code true} if list is empty, {@code false} otherwise
94+
*/
95+
@Override
96+
public boolean isEmpty() {
97+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
98+
}
99+
100+
/**
101+
* Returns the number of elements in the list
102+
*
103+
* @return number of elements
104+
*/
105+
@Override
106+
public int size() {
107+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
108+
}
109+
110+
/**
111+
* Removes all list elements
112+
*/
113+
@Override
114+
public void clear() {
115+
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
116+
}
117+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.bobocode.LinkedList;
2+
3+
4+
public interface List<T> {
5+
void add(T element);
6+
7+
void add(int index, T element);
8+
9+
void set(int index, T element);
10+
11+
T get(int index);
12+
13+
void remove(int index);
14+
15+
boolean contains(T element);
16+
17+
boolean isEmpty();
18+
19+
int size();
20+
21+
void clear();
22+
23+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /