Code example for LinkedList

Methods: addFirstcontains

0
			segments.addLast(path.getSegment(i));
		} 
	} 
 
	public void addParent(Object segment) throws IllegalArgumentException {
		if (segments.contains(segment)) {
			throw createCyclicPathException(segment);
		} 
		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());
	}