Esempio n. 1
0
 public static <U> IDequeSequence<U> fromDequeWithValues(
     Deque<U> deque, Iterable<? extends U> it) {
   Deque<U> tmp = deque;
   if (Sequence.USE_NULL_SEQUENCE) {
     if (deque == null && it == null) {
       return NullDequeSequence.instance();
     } else if (deque == null) {
       tmp = new LinkedList<U>();
     } else if (it == null) {
       return DequeSequence.fromDeque(deque);
     }
   }
   if (Sequence.IGNORE_NULL_VALUES) {
     for (U u : it) {
       if (u != null) {
         tmp.add(u);
       }
     }
   } else if (it instanceof Collection) {
     tmp.addAll((Collection<? extends U>) it);
   } else {
     for (U u : it) {
       tmp.add(u);
     }
   }
   if (tmp instanceof IDequeSequence) {
     return (IDequeSequence<U>) tmp;
   }
   return new DequeSequence<U>(tmp);
 }
Esempio n. 2
0
 public static <U> IDequeSequence<U> fromIterable(Iterable<U> it) {
   if (Sequence.USE_NULL_SEQUENCE) {
     if (it == null) {
       return NullDequeSequence.instance();
     }
   }
   if (it instanceof IDequeSequence) {
     return (IDequeSequence<U>) it;
   }
   Deque<U> deque = new LinkedList<U>();
   if (Sequence.IGNORE_NULL_VALUES) {
     for (U u : it) {
       if (u != null) {
         deque.add(u);
       }
     }
   } else if (it instanceof Collection) {
     deque.addAll((Collection<? extends U>) it);
   } else {
     for (U u : it) {
       deque.add(u);
     }
   }
   return new DequeSequence<U>(deque);
 }
Esempio n. 3
0
 public static <U> IDequeSequence<U> fromDequeAndArray(Deque<U> deque, U... array) {
   if (Sequence.NULL_ARRAY_IS_SINGLETON) {
     if (array == null) {
       array = (U[]) Sequence.nullSingletonArray();
     }
   }
   if (Sequence.USE_NULL_SEQUENCE) {
     if (deque == null && array == null) {
       return NullDequeSequence.instance();
     } else if (deque == null) {
       deque = new LinkedList<U>();
     } else if (array == null) {
       if (deque instanceof IDequeSequence) {
         return (IDequeSequence<U>) deque;
       }
       return new DequeSequence<U>(deque);
     }
   }
   List<U> input = Arrays.asList(array);
   if (Sequence.IGNORE_NULL_VALUES) {
     for (U u : input) {
       if (u != null) {
         deque.add(u);
       }
     }
   } else {
     deque.addAll(input);
   }
   if (deque instanceof IDequeSequence) {
     return (IDequeSequence<U>) deque;
   }
   return new DequeSequence<U>(deque);
 }