tree-tree.html

来自「经典的数据结构源代码(java 实现)」· HTML 代码 · 共 46 行

HTML
46
字号
<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&lt;E&gt; {  <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&lt;E&gt; <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&lt;Position&lt;E&gt;&gt; <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&lt;E&gt; 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&lt;E&gt; <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&lt;E&gt; <font color=#0000ff>parent</font>(Position&lt;E&gt; 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&lt;Position&lt;E&gt;&gt; <font color=#0000ff>children</font>(Position&lt;E&gt; 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&lt;E&gt; 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&lt;E&gt; 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&lt;E&gt; v)    <font color=#8000a0><font color=#ff8000>throws</font> </font>InvalidPositionException;}</dl></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?