Browse Source

generic stack

Daniel Zlotin 7 years ago
parent
commit
f795aa4a6e

+ 17
- 0
lib/android/app/src/main/java/com/reactnativenavigation/utils/Stack.java View File

1
+package com.reactnativenavigation.utils;
2
+
3
+public interface Stack<E> extends Iterable<E> {
4
+
5
+	void push(E element);
6
+
7
+	E pop();
8
+
9
+	E peek();
10
+
11
+	boolean remove(E element);
12
+
13
+	int size();
14
+
15
+	boolean isEmpty();
16
+
17
+}

+ 6
- 0
lib/android/app/src/main/java/com/reactnativenavigation/utils/StackImpl.java View File

1
+package com.reactnativenavigation.utils;
2
+
3
+import java.util.ArrayDeque;
4
+
5
+public class StackImpl<E> extends ArrayDeque<E> implements Stack<E> {
6
+}

+ 4
- 3
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java View File

4
 import android.view.ViewGroup;
4
 import android.view.ViewGroup;
5
 import android.widget.FrameLayout;
5
 import android.widget.FrameLayout;
6
 
6
 
7
-import java.util.ArrayDeque;
7
+import com.reactnativenavigation.utils.Stack;
8
+import com.reactnativenavigation.utils.StackImpl;
8
 
9
 
9
 public class StackController extends ViewController {
10
 public class StackController extends ViewController {
10
-	private ArrayDeque<ViewController> childControllers = new ArrayDeque<>();
11
+	private Stack<ViewController> childControllers = new StackImpl<>();
11
 
12
 
12
 	public StackController(final Activity activity) {
13
 	public StackController(final Activity activity) {
13
 		super(activity);
14
 		super(activity);
18
 		return (ViewGroup) super.getView();
19
 		return (ViewGroup) super.getView();
19
 	}
20
 	}
20
 
21
 
21
-	public ArrayDeque<ViewController> getChildControllers() {
22
+	public Stack<ViewController> getChildControllers() {
22
 		return childControllers;
23
 		return childControllers;
23
 	}
24
 	}
24
 
25