-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDequeFactory.java
More file actions
52 lines (47 loc) · 1.36 KB
/
DequeFactory.java
File metadata and controls
52 lines (47 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package javasabr.rlib.collections.deque;
import java.util.Deque;
import javasabr.rlib.collections.deque.impl.DefaultArrayBasedDeque;
import javasabr.rlib.collections.deque.impl.DefaultLinkedListBasedDeque;
import lombok.experimental.UtilityClass;
/**
* Factory for creating various deque implementations.
*
* @author JavaSaBr
* @since 10.0.0
*/
@UtilityClass
public class DequeFactory {
/**
* Creates a new deque backed by a linked list.
*
* @param <E> the type of elements
* @return a new linked list based deque
* @since 10.0.0
*/
public static <E> Deque<E> linkedListBased() {
return new DefaultLinkedListBasedDeque<>();
}
/**
* Creates a new deque backed by an array.
*
* @param <E> the type of elements
* @param type the component type of the array
* @return a new array based deque
* @since 10.0.0
*/
public static <E> Deque<E> arrayBased(Class<? super E> type) {
return new DefaultArrayBasedDeque<>(type);
}
/**
* Creates a new deque backed by an array with initial capacity.
*
* @param <E> the type of elements
* @param type the component type of the array
* @param capacity the initial capacity
* @return a new array based deque
* @since 10.0.0
*/
public static <E> Deque<E> arrayBased(Class<? super E> type, int capacity) {
return new DefaultArrayBasedDeque<>(type, capacity);
}
}