Alien-Judy

 view release on metacpan or  search on metacpan

src/judy-1.0.5/doc/ext/JudySL_3.htm  view on Meta::CPAN

<HTML>
<HEAD>
<!-- @(#) $Revision: 4.43 $ $Source: /cvsroot/judy/doc/ext/JudySL_3.htm,v $ --->
<TITLE>JudySL(3)</TITLE>
</HEAD>
<BODY>
<TABLE border=0 width="100%"><TR>
<TD width="40%" align="left">JudySL(3)</TD>
<TD width="10%" align="center">     </TD>
<TD width="40%" align="right">JudySL(3)</TD>
</TR></TABLE>
<P>
<DL>
<!----------------->
<DT><B>NAME</B></DT>
<DD>
JudySL macros -
C library for creating and accessing a dynamic array, using
a null-terminated string as an <B>Index</B> (associative array)
<!----------------->
<P>
<DT><B>SYNOPSIS</B></DT>
<DD>
<B><PRE>
cc [flags] <I>sourcefiles</I> -lJudy

#include &lt;Judy.h&gt;

#define MAXLINELEN 1000000           // define maximum string length

Word_t * PValue;                     // JudySL array element
uint8_t  Index[MAXLINELEN];          // string
int      Rc_int;                     // return value
Word_t   Rc_word;                    // full word return value

Pvoid_t PJSLArray = (Pvoid_t) NULL;  // initialize JudySL array

<A href="#JSLI" >JSLI</A>( PValue,  PJSLArray, Index);   // <A href="JudySL_funcs_3.htm#JudySLIns">JudySLIns()</A>
<A href="#JSLD" >JSLD</A>( Rc_int,  PJSLArray, Index);   // <A href="JudySL_funcs_3.htm#JudySLDel">JudySLDel()</A>
<A href="#JSLG" >JSLG</A>( PValue,  PJSLArray, Index);   // <A href="JudySL_funcs_3.htm#JudySLGet">JudySLGet()</A>
<A href="#JSLFA">JSLFA</A>(Rc_word, PJSLArray);          // <A href="JudySL_funcs_3.htm#JudySLFreeArray">JudySLFreeArray()</A>
<A href="#JSLF" >JSLF</A>( PValue,  PJSLArray, Index);   // <A href="JudySL_funcs_3.htm#JudySLFirst">JudySLFirst()</A>
<A href="#JSLN" >JSLN</A>( PValue,  PJSLArray, Index);   // <A href="JudySL_funcs_3.htm#JudySLNext">JudySLNext()</A>
<A href="#JSLL" >JSLL</A>( PValue,  PJSLArray, Index);   // <A href="JudySL_funcs_3.htm#JudySLLast">JudySLLast()</A>
<A href="#JSLP" >JSLP</A>( PValue,  PJSLArray, Index);   // <A href="JudySL_funcs_3.htm#JudySLPrev">JudySLPrev()</A>

</PRE></B>
<!----------------->
<P>
<DT><B>DESCRIPTION</B></DT>
<DD>
A JudySL array is the equivalent of a sorted set of strings, each associated
with a <B>Value</B> (word).
A <B>Value</B> is addressed by an <B>Index</B> (key), which is a null-terminated
character string of any length.
Memory to support the array is allocated as index/value pairs are inserted,
and released as index/value pairs are deleted.
This is a form of associative array, where array elements are also sorted
lexicographically (case-sensitive) by indexes.
This could be thought of as
<P><PRE>
void * JudySLArray["Toto, I don't think we're in Kansas any more"];
</PRE>
<P>
A JudySL array is allocated with a <B>NULL</B> pointer
<PRE>
Pvoid_t PJSLArray = (Pvoid_t) NULL;
</PRE>
As with an ordinary array, there are no duplicate indexes (strings)
in a JudySL array.
<P>
Using the macros described here, rather than the
<A href="JudySL_funcs_3.htm">JudySL function calls</A>,
the default error handling sends a
message to the standard error and terminates the program with
<B>exit(1)</B>.
<P>
<DT><A name="JSLI"><B>JSLI(PValue, PJSLArray, Index)</B></A> // <A href="JudySL_funcs_3.htm#JudySLIns">JudySLIns()</A></DT>
<DD>
Insert an <B>Index</B> string and <B>Value</B> in the JudySL array <B>PJSLArray</B>.
If the <B>Index</B> is successfully inserted,
the <B>Value</B> is initialized to 0. If the <B>Index</B> was already present,
the <B>Value</B> is not modified.
<P>
Return <B>PValue</B> pointing to <B>Index</B>'s <B>Value</B>.



( run in 1.411 second using v1.01-cache-2.11-cpan-140bd7fdf52 )