Package aterm

Examples of aterm.ATermList


    if (first == null) {
      return this;
    }

    ATerm head = first.make(args);
    ATermList tail = (ATermList) next.make(args);
    if (isListPlaceHolder(first)) {
      /*
       * this is to solve the make([<list>],[]) problem the result should
       * be [] and not [[]] to be compatible with the C version
       */
      return head;
    }
    return tail.insert(head);

  }
View Full Code Here


  public ATermList getNext() {
    return next;
  }

  public ATerm getLast() {
    ATermList cur;

    cur = this;
    while (!cur.getNext().isEmpty()) {
      cur = cur.getNext();
    }

    return cur.getFirst();
  }
View Full Code Here

    return cur.getFirst();
  }

  public int indexOf(ATerm el, int start) {
    int i;
    ATermList cur;

    if (start < 0) {
      start += length + 1;
    }

    if (start > length) {
      throw new IllegalArgumentException("start (" + start + ") > length of list (" + length + ")");
    }

    cur = this;
    for (i = 0; i < start; i++) {
      cur = cur.getNext();
    }

    while (!cur.isEmpty() && cur.getFirst() != el) {
      cur = cur.getNext();
      ++i;
    }

    return cur.isEmpty() ? -1 : i;
  }
View Full Code Here

  public ATerm elementAt(int index) {
    if (0 > index || index >= length) {
      throw new IllegalArgumentException("illegal list index: " + index);
    }

    ATermList cur = this;
    for (int i = 0; i < index; i++) {
      cur = cur.getNext();
    }

    return cur.getFirst();
  }
View Full Code Here

  public ATermList remove(ATerm el) {
    if (first == el) {
      return next;
    }

    ATermList result = next.remove(el);

    if (result == next) {
      return this;
    }

    return result.insert(first);
  }
View Full Code Here

  public ATermList removeAll(ATerm el) {
    if (first == el) {
      return next.removeAll(el);
    }

    ATermList result = next.removeAll(el);

    if (result == next) {
      return this;
    }

    return result.insert(first);
  }
View Full Code Here

  public ATermList getPrefix() {
    if (isEmpty()) {
      return this;
    }

    ATermList cur = this;
    List<ATerm> elems = new ArrayList<ATerm>();

    while (true) {
      if (cur.getNext().isEmpty()) {
        cur = getPureFactory().getEmpty();
        for (int i = elems.size() - 1; i >= 0; i--) {
          cur = cur.insert(elems.get(i));
        }
        return cur;
      }
      elems.add(cur.getFirst());
      cur = cur.getNext();
    }
  }
View Full Code Here

  }

  public ATermList getSlice(int start, int end) {
    int i, size = end - start;
   
    ATermList list = this;
    for (i = 0; i < start; i++) {
      list = list.getNext();
    }

    List<ATerm> buffer = new ArrayList<ATerm>(size);
    for (i = 0; i < size; i++) {
      buffer.add(list.getFirst());
      list = list.getNext();
    }
   
    ATermList result = getPureFactory().getEmpty();
    for (--i; i >= 0; i--) {
      result = result.insert(buffer.get(i));
    }

    return result;
  }
View Full Code Here

    if (0 > i || i > length) {
      throw new IllegalArgumentException("illegal list index: " + i);
    }

    List<ATerm> buffer = new ArrayList<ATerm>(i);
    ATermList cur = this;
   
    for (lcv = 0; lcv < i; lcv++) {
      buffer.add(cur.getFirst());
      cur = cur.getNext();
    }

    /* Skip the old element */
    cur = cur.getNext();

    /* Add the new element */
    cur = cur.insert(el);

    /* Add the prefix */
    for (--lcv; lcv >= 0; lcv--) {
      cur = cur.insert(buffer.get(lcv));
    }

    return cur;
  }
View Full Code Here

    return cur;
  }

  public ATermList reverse() {
    ATermList cur = this;
    ATermList reverse = this.getEmpty();
    while (!cur.isEmpty()) {
      reverse = reverse.insert(cur.getFirst());
      cur = cur.getNext();
    }
    return reverse;
  }
View Full Code Here

TOP

Related Classes of aterm.ATermList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.