public boolean equalp(SubLObject obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (!obj.isList()) {
     return false;
   }
   SubLList otherCons = obj.toList();
   SubLListListIterator iter1 = null;
   SubLListListIterator iter2 = null;
   Resourcer resourcer = Resourcer.getInstance();
   try {
     iter1 = resourcer.acquireSubLListListIterator(this);
     iter2 = resourcer.acquireSubLListListIterator(otherCons);
     while (iter1.hasNext() && (!iter1.isNextImproperElement())) {
       if (!iter2.hasNext()) {
         return false;
       }
       if (!iter1.nextSubLObject().equalp(iter2.nextSubLObject())) {
         return false;
       }
     }
     if (iter1.isNextImproperElement()) {
       if (iter2.isNextImproperElement()) {
         return iter1.getDottedElement().equalp(iter2.getDottedElement());
       }
       return false;
     } else if (iter2.hasNext()) {
       // iter1 is prefix of iter2 case
       return false;
     }
     // they will be equalp at this point
     return true;
   } finally {
     resourcer.releaseSubLListListIterator(iter1);
     resourcer.releaseSubLListListIterator(iter2);
   }
 }
 public SubLList assoc(SubLObject item, BinaryFunction test, UnaryFunction key) {
   SubLObject currentItem = null;
   SubLList result = SubLNil.NIL;
   SubLListListIterator iter = null;
   Resourcer resourcer = Resourcer.getInstance();
   SubLList curAssoc;
   try {
     iter = resourcer.acquireSubLListListIterator(this);
     while (iter.hasNext()) {
       curAssoc = iter.nextSubLObject().toList();
       if (SubLNil.NIL != test.processItem(item, key.processItem(curAssoc.first()))) {
         result = curAssoc;
         break;
       }
     }
   } finally {
     resourcer.releaseSubLListListIterator(iter);
   }
   return result;
 }
 private final SubLList mapResult(
     SubLFunction function, SubLObject[] moreLists, boolean returnConsedResults) {
   ArrayList<SubLObject> results = new ArrayList<SubLObject>();
   SubLListListIterator[] iterators =
       new SubLListListIterator[1 + moreLists.length]; // @todo get rid of call to new -APB
   int iteratorCount = iterators.length;
   SubLObject[] args = null;
   Resourcer resourcer = Resourcer.getInstance();
   try {
     args = resourcer.acquireSubLObjectArray(iteratorCount);
     iterators[0] = resourcer.acquireSubLListListIterator(this);
     for (int i = 0, size = moreLists.length; i < size; i++) {
       iterators[i + 1] = resourcer.acquireSubLListListIterator(moreLists[i].toList());
     }
     SubLListListIterator iter = null;
     SubLObject curResult = null;
     while (true) {
       for (int i = 0; i < iteratorCount; i++) {
         iter = iterators[i];
         if (!iter.hasNext()) {
           return SubLObjectFactory.makeList(results);
         }
         if (iter.isNextImproperElement()) {
           Errors.error("Unexpected improper list: " + ((i == 0) ? this : moreLists[i - 1]));
         }
         args[i] = iter.nextSubLObject();
       }
       curResult = Functions.funcall(function, args);
       if (results != null) {
         results.add(curResult);
       }
     }
   } finally {
     resourcer.releaseSubLObjectArray(args);
     for (int i = 0, size = iterators.length; i < size; i++) {
       resourcer.releaseSubLListListIterator(iterators[i]);
     }
   }
 }
 public int hashCode(int currentDepth) {
   if (currentDepth < MAX_HASH_DEPTH) {
     SubLListListIterator iter = null;
     Resourcer resourcer = Resourcer.getInstance();
     int hashCode = 0;
     try {
       int index = 0;
       iter = resourcer.acquireSubLListListIterator(this);
       while (iter.hasNext() && (!iter.isNextImproperElement()) && (index++ < MAX_HASH_LENGTH)) {
         hashCode ^= iter.nextSubLObject().hashCode(currentDepth + 1);
         index++;
       }
       if (iter.isNextImproperElement()) {
         hashCode ^= iter.getDottedElement().hashCode(currentDepth + 1);
       }
       return hashCode;
     } finally {
       resourcer.releaseSubLListListIterator(iter);
     }
   } else {
     return DEFAULT_EXCEEDED_HASH_VALUE;
   }
 }