Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/rxm.git

Removed unused stack implementation.

Author Dave Jarvis <email>
Date 2015-03-03 23:07:18 GMT-0800
Commit cff74d93f892594f4e1b06b243219d8388c742d1
Parent fe9e002
source/java/com/whitemagicsoftware/rxm/SilentStack.java
-package com.whitemagicsoftware.rxm;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.NoSuchElementException;
-import java.util.Iterator;
-
-/**
- * Captures and silently ignores stack exceptions.
- */
-public abstract class SilentStack<E> extends ArrayDeque<E> {
- /**
- * Returns the top-most value off the stack, or a new instance of E
- * if the stack is empty. This removes the object from the stack.
- *
- * @return The top-most element on the stack.
- */
- public E pop() {
- try {
- return super.pop();
- }
- catch( NoSuchElementException nsee ) {
- return create();
- }
- }
-
- /**
- * Creates a new instance of the generic type E. This should not ever
- * return null.
- *
- * @return A new instance of E, or null if it could not be instantiated.
- */
- @SuppressWarnings("unchecked")
- private E create() {
- try {
- Type sooper = getClass().getGenericSuperclass();
- Type t = ((ParameterizedType)sooper).getActualTypeArguments()[ 0 ];
-
- return (E)(Class.forName( t.toString() ).newInstance());
- }
- catch( Exception e ) {
- return null;
- }
- }
-
- public Iterable<E> inReverse() {
- return new Iterable<E>() {
- public Iterator<E> iterator() {
- return descendingIterator();
- }
- };
- }
-}
-
Delta 0 lines added, 57 lines removed, 57-line decrease