public final class MutableTreeImpl<E> extends AbstractSettableNode<E,MutableSettableNode<E>> implements MutableTree<E,MutableSettableNode<E>>, MutableSettableNode<E>
The problem is that modifications to grandchildren can still be seen because of the shallow copy. The problem with this is the modifications can be observed out of order. The modification to the grandchildren is made after the parent but seen first.
elementReference
Constructor and Description |
---|
MutableTreeImpl(E element) |
Modifier and Type | Method and Description |
---|---|
MutableTreeImpl<E> |
addChild(E e)
Add a child
|
Iterator<MutableSettableNode<E>> |
childIterator() |
int |
getNumberOfChildren() |
MutableTreeImpl<E> |
getRoot() |
boolean |
isEmpty() |
boolean |
removeChild(MutableSettableNode<E> child)
Remove the node if it is a child of the recipient
|
MutableTreeImpl<E> |
setRoot(E root)
Set the root element.
|
static <E> TypeKey<MutableTreeImpl<E>> |
typeKey()
Construct a TypeKey for a specific element type.
|
getElement, setElement
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setElement
getElement, getElementClass, isLeaf
public MutableTreeImpl(E element)
public MutableTreeImpl<E> addChild(E e)
NodeAppender
addChild
in interface NodeAppender<E,MutableSettableNode<E>>
e
- The element of the child to addpublic boolean removeChild(MutableSettableNode<E> child)
OpenMutableNode
removeChild
in interface OpenMutableNode<E,MutableSettableNode<E>>
child
- the node to removetrue
if the node was removedpublic MutableTreeImpl<E> getRoot()
getRoot
in interface Tree<E,MutableSettableNode<E>>
public boolean isEmpty()
isEmpty
in interface Tree<E,MutableSettableNode<E>>
true
if the tree is emptypublic MutableTreeImpl<E> setRoot(E root)
MutableTree
setRoot
in interface MutableTree<E,MutableSettableNode<E>>
root
- Root element.public static <E> TypeKey<MutableTreeImpl<E>> typeKey()
typeKey
in interface MutableTree<E,MutableSettableNode<E>>
typeKey
in interface Tree<E,MutableSettableNode<E>>
E
- The element typepublic int getNumberOfChildren()
getNumberOfChildren
in interface OpenNode<E,MutableSettableNode<E>>
public Iterator<MutableSettableNode<E>> childIterator()
childIterator
in interface OpenNode<E,MutableSettableNode<E>>
Copyright © 2014–2016. All rights reserved.