Code example for LinkedList

Methods: addLast, contains

0
segments.addFirst(segment);
	} 
 
	public void addChild(Object segment) throws IllegalArgumentException {
		if (segments.contains(segment)) {
			throw createCyclicPathException(segment);
		} 
		segments.addLast(segment);
	} 
 
	public TreePath getPath() { 
		return new TreePath(segments.toArray());
	} 
 
	public TreePath getParentPath() { 
		LinkedList parentSegments = new LinkedList<Object>(segments);
		parentSegments.removeLast();
		return new TreePath(parentSegments.toArray());
	}