📄 tree-tree.html
字号:
<html><head><title>Code Fragment</title></head><body text=#000000><center></center><br><br><dl><dd><pre><font color=#ff0080>/** * An interface for a tree where nodes can have an arbitrary number of children. */</font><font color=#8000a0>public</font> <font color=#8000a0><font color=#ff8000>interface</font> </font>Tree<E> { <font color = #ff0080>/** Returns the number of nodes in the tree. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>int</font> <font color=#0000ff>size</font>(); <font color = #ff0080>/** Returns whether the tree is empty. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>boolean</font> <font color=#0000ff>isEmpty</font>(); <font color = #ff0080>/** Returns an iterator of the elements stored in the tree. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font>Iterator<E> <font color=#0000ff>iterator</font>(); <font color = #ff0080>/** Returns an iterable collection of the the nodes. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font>Iterable<Position<E>> <font color=#0000ff>positions</font>(); <font color = #ff0080>/** Replaces the element stored at a given node. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font>E <font color=#0000ff>replace</font>(Position<E> v, <font color=#8000a0>E </font>e) <font color=#8000a0><font color=#ff8000>throws</font> </font>InvalidPositionException; <font color = #ff0080>/** Returns the root of the tree. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font>Position<E> <font color=#0000ff>root</font>() <font color=#8000a0><font color=#ff8000>throws</font> </font>EmptyTreeException; <font color = #ff0080>/** Returns the parent of a given node. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font>Position<E> <font color=#0000ff>parent</font>(Position<E> v) <font color=#8000a0><font color=#ff8000>throws</font> </font>InvalidPositionException, BoundaryViolationException; <font color = #ff0080>/** Returns an iterable collection of the children of a given node. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font>Iterable<Position<E>> <font color=#0000ff>children</font>(Position<E> v) <font color=#8000a0><font color=#ff8000>throws</font> </font>InvalidPositionException; <font color = #ff0080>/** Returns whether a given node is internal. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>boolean</font> <font color=#0000ff>isInternal</font>(Position<E> v) <font color=#8000a0><font color=#ff8000>throws</font> </font>InvalidPositionException; <font color = #ff0080>/** Returns whether a given node is external. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>boolean</font> <font color=#0000ff>isExternal</font>(Position<E> v) <font color=#8000a0><font color=#ff8000>throws</font> </font>InvalidPositionException; <font color = #ff0080>/** Returns whether a given node is the root of the tree. */</font> <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>boolean</font> <font color=#0000ff>isRoot</font>(Position<E> v) <font color=#8000a0><font color=#ff8000>throws</font> </font>InvalidPositionException;}</dl></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -