Created
May 9, 2014 14:15
-
-
Save fge/f0b61f7b5e1df73a9f60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| @SuppressWarnings("unchecked") | |
| public void pushAll(final V firstValue, final V... moreValues) | |
| { | |
| // FIXME: hackish :/ Can throw ClassCastException all right | |
| if (firstValue instanceof Iterable | |
| && moreValues != null | |
| && moreValues.length == 0) { | |
| pushAll((Iterable<V>) firstValue); | |
| return; | |
| } | |
| final Deque<V> deque = new LinkedList<V>(); | |
| // FIXME: null sucks | |
| if (moreValues == null) | |
| deque.push(null); | |
| else | |
| deque.addAll(Arrays.asList(moreValues)); | |
| deque.push(firstValue); | |
| pushAll(deque); | |
| } | |
| /** | |
| * Pushes all given elements onto the stack (in the order as given). | |
| * | |
| * @param values the values | |
| */ | |
| @Override | |
| public void pushAll(@Nonnull final Iterable<V> values) | |
| { | |
| final List<V> newStack = Lists.newArrayList(values); | |
| newStack.addAll(stack); | |
| stack = newStack; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment