Beispiel #1
0
 /** @return */
 public LinkedQueue<T> chompClone() {
   final LinkedQueue<T> q = new LinkedQueue<>();
   Node<T> n = base;
   while (n != this.end) {
     q.enqueue(n.value);
     n = n.tail;
   }
   if (chomped) q.chomp();
   return q;
 }
Beispiel #2
0
 /**
  * @param n
  * @param q
  * @param productions
  */
 public final void replace(final T s, final LinkedQueue<T> q) {
   if (q.isEmpty()) removeAll(s);
   if (q.isSingleton()) replace(s, q.peek());
   final Node<T> end = chomped ? this.end : null;
   for (Node<T> n = this.base; n != end; n = n.tail)
     if (n.value == s) {
       final Node<T> tail = n.tail;
       final Iterator<T> it = q.iterator();
       do {
         final T t = it.next();
         n.value = t;
         n.tail = new Node<T>();
         if (!it.hasNext()) break;
         n = n.tail;
       } while (true);
       n.tail = tail;
     }
 }
Beispiel #3
0
 /** @return */
 public LinkedQueue<T> enqueueClone(final T end) {
   final LinkedQueue<T> q = new LinkedQueue<>();
   for (final T n : this) q.enqueue(n);
   q.enqueue(end);
   return q;
 }
Beispiel #4
0
 @Override
 public LinkedQueue<T> clone() {
   final LinkedQueue<T> q = new LinkedQueue<>();
   for (final T n : this) q.enqueue(n);
   return q;
 }
Beispiel #5
0
 /**
  * @param n
  * @return
  */
 public LinkedQueue<T> without(final T n) {
   final LinkedQueue<T> output = new LinkedQueue<>();
   for (final T v : this) if (!v.equals(n)) output.enqueue(v);
   return output;
 }