public ItemList sublist(int start) { if ( _size() < start+offset ) return null ; ItemList x = new ItemList(noLine, noColumn, offset+start, elements) ; return x ; }
/** Slice of the list from start (inclusive) to finish (exclusive) */ public ItemList sublist(int start, int finish) { if ( start < 0 || finish < 0 || finish < start ) return null ; if ( _size() < start ) return null ; if ( finish > _size() ) return null ; ItemList x = new ItemList() ; // Take a slice. // Note : this is a copy. // Note: List.subList just puts a wrapper around the overlying list // but don't do this a lot because ArrayList.get recurses to the core list (may run out of stack). // Better would an adjusting slice over base array but it's quite tricky to do the calculations correctly. // This way is mnore likely to be correct. x.elements.addAll(elements.subList(start+offset, finish+offset)) ; return x ; }
public static Item createList(int line, int column) { Item item = new Item(line, column) ; item.list = new ItemList(line, column) ; return item ; }
@Override public void listStart(int line, int column) { ItemList list = new ItemList(line, column) ; pushList(list) ; setCurrentItem(Item.createList(list)) ; }
public ItemList cdrOrNull() { if ( _size() == 0 ) return null ; ItemList x = new ItemList(super.getLine(), super.getColumn(), offset+1, elements) ; return x ; }
public ItemList cdr() { if ( _size() == 0 ) throw new ItemException("ItemList.cdr: list is zero length") ; ItemList x = new ItemList(super.getLine(), super.getColumn(), offset+1, elements) ; return x ; }
ItemList il = new ItemList(); il.add(function.asNode()); for(int i = 0; i < args.size(); i++) {
private static void addTypeTriple(ItemList statsList, Node type, Node intCount) { ItemList triple = new ItemList() ; triple.add("VAR") ; triple.add(NodeConst.nodeRDFType) ; triple.add(type) ; addPair(statsList, Item.createList(triple), Item.createNode(intCount)) ; } }
private static void addTypeTriple(ItemList statsList, Node type, Node intCount) { ItemList triple = new ItemList() ; triple.add("VAR") ; triple.add(NodeConst.nodeRDFType) ; triple.add(type) ; addPair(statsList, Item.createList(triple), Item.createNode(intCount)) ; } }
@Override public void visit(Item item, ItemList list) { ItemList newList = new ItemList(item.getLine(), item.getColumn()) ; for ( Item subItem : list ) { subItem.visit(this) ; Item newItem = pop(); newList.add(newItem) ; } Item newItemList = Item.createList(newList, item.getLine(), item.getColumn()) ; push(newItemList) ; }