📄 ternarytree.html
字号:
char val)</CODE><BR> The actual insertion function, recursive version.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#insert(java.lang.String, char)">insert</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> key, char val)</CODE><BR> Branches are initially compressed, needing one node per key plus the size of the string key.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#insertBalanced(java.lang.String[], char[], int, int)">insertBalanced</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>[] k, char[] v, int offset, int n)</CODE><BR> Recursively insert the median first and then the median of the lower and upper halves, and so on in order to get a balanced tree.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/util/Enumeration.html?is-external=true" title="class or interface in java.util">Enumeration</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#keys()">keys</A></B>()</CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#knows(java.lang.String)">knows</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> key)</CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#printStats()">printStats</A></B>()</CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>private void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#redimNodeArrays(int)">redimNodeArrays</A></B>(int newsize)</CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#size()">size</A></B>()</CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#strcmp(char[], int, char[], int)">strcmp</A></B>(char[] a, int startA, char[] b, int startB)</CODE><BR> Compares 2 null terminated char arrays</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#strcmp(java.lang.String, char[], int)">strcmp</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> str, char[] a, int start)</CODE><BR> Compares a string with null terminated char array</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#strcpy(char[], int, char[], int)">strcpy</A></B>(char[] dst, int di, char[] src, int si)</CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#strlen(char[])">strlen</A></B>(char[] a)</CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#strlen(char[], int)">strlen</A></B>(char[] a, int start)</CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/hyphenation/TernaryTree.html#trimToSize()">trimToSize</A></B>()</CODE><BR> Each node stores a character (splitchar) which is part of some key(s).</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><A NAME="field_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Field Detail</B></FONT></TH></TR></TABLE><A NAME="serialVersionUID"><!-- --></A><H3>serialVersionUID</H3><PRE>private static final long <B>serialVersionUID</B></PRE><DL><DD>We use 4 arrays to represent a node. I guess I should have created a proper node class, but somehow Knuth's pascal code made me forget we now have a portable language with virtual memory management and automatic garbage collection! And now is kind of late, furthermore, if it ain't broken, don't fix it.<P><DL><DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#com.lowagie.text.pdf.hyphenation.TernaryTree.serialVersionUID">Constant Field Values</A></DL></DL><HR><A NAME="lo"><!-- --></A><H3>lo</H3><PRE>protected char[] <B>lo</B></PRE><DL><DD>Pointer to low branch and to rest of the key when it is stored directly in this node, we don't have unions in java!<P><DL></DL></DL><HR><A NAME="hi"><!-- --></A><H3>hi</H3><PRE>protected char[] <B>hi</B></PRE><DL><DD>Pointer to high branch.<P><DL></DL></DL><HR><A NAME="eq"><!-- --></A><H3>eq</H3><PRE>protected char[] <B>eq</B></PRE><DL><DD>Pointer to equal branch and to data when this node is a string terminator.<P><DL></DL></DL><HR><A NAME="sc"><!-- --></A><H3>sc</H3><PRE>protected char[] <B>sc</B></PRE><DL><DD><P>The character stored in this node: splitchar. Two special values are reserved:</P> <ul><li>0x0000 as string terminator</li> <li>0xFFFF to indicate that the branch starting at this node is compressed</li></ul> <p>This shouldn't be a problem if we give the usual semantics to strings since 0xFFFF is guaranteed not to be an Unicode character.</p><P><DL></DL></DL><HR><A NAME="kv"><!-- --></A><H3>kv</H3><PRE>protected <A HREF="../../../../../com/lowagie/text/pdf/hyphenation/CharVector.html" title="class in com.lowagie.text.pdf.hyphenation">CharVector</A> <B>kv</B></PRE><DL><DD>This vector holds the trailing of the keys when the branch is compressed.<P><DL></DL></DL><HR><A NAME="root"><!-- --></A><H3>root</H3><PRE>protected char <B>root</B></PRE><DL><DL></DL></DL><HR><A NAME="freenode"><!-- --></A><H3>freenode</H3><PRE>protected char <B>freenode</B></PRE><DL><DL></DL></DL><HR><A NAME="length"><!-- --></A><H3>length</H3><PRE>protected int <B>length</B></PRE><DL><DL></DL></DL><HR><A NAME="BLOCK_SIZE"><!-- --></A><H3>BLOCK_SIZE</H3><PRE>protected static final int <B>BLOCK_SIZE</B></PRE><DL><DL><DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#com.lowagie.text.pdf.hyphenation.TernaryTree.BLOCK_SIZE">Constant Field Values</A></DL></DL><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TH></TR></TABLE><A NAME="TernaryTree()"><!-- --></A><H3>TernaryTree</H3><PRE><B>TernaryTree</B>()</PRE><DL></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Method Detail</B></FONT></TH></TR></TABLE><A NAME="init()"><!-- --></A><H3>init</H3><PRE>protected void <B>init</B>()</PRE><DL><DD><DL></DL></DD><DD><DL></DL></DD></DL><HR><A NAME="insert(java.lang.String, char)"><!-- --></A><H3>insert</H3><PRE>public void <B>insert</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> key, char val)</PRE><DL><DD>Branches are initially compressed, needing one node per key plus the size of the string key. They are decompressed as needed when another key with same prefix is inserted. This saves a lot of space, specially for long keys.<P><DD><DL></DL></DD><DD><DL></DL></DD></DL><HR><A NAME="insert(char[], int, char)"><!-- --></A><H3>insert</H3><PRE>public void <B>insert</B>(char[] key, int start, char val)</PRE><DL><DD><DL></DL></DD><DD><DL></DL></DD></DL><HR><A NAME="insert(char, char[], int, char)"><!-- --></A><H3>insert</H3><PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -