Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/doc/ext/JudyHS_3.htm view on Meta::CPAN
<DT><A name="JHSD"><B>JHSD(Rc_int, PJHSArray, Index, Length)</B></A> // <A href="JudyHS_funcs_3.htm#JudyHSDel">JudyHSDel()</A></DT>
<DD>
Given a pointer to a JudyHS array (<B>PJHSArray</B>), delete the
specified <B>Index</B> along with the <B>Value</B> from the JudyHS
array.
<P>
Return <B>Rc_int</B> set to 1 if successfully removed from the array.
Return <B>Rc_int</B> set to 0 if <B>Index</B> was not present.
<P>
<DT><A name="JHSG"><B>JHSG(PValue, PJHSArray, Index, Length)</B></A> // <A href="JudyHS_funcs_3.htm#JudyHSGet">JudyHSGet()</A></DT>
<DD>
Given a pointer to a JudyHS array (<B>PJHSArray</B>),
find <B>Value</B> associated with <B>Index</B>.
<P>
Return <B>PValue</B> pointing to <B>Index</B>'s <B>Value</B>.
Return <B>PValue</B> set to <B>NULL</B> if the <B>Index</B> was not present.
<P>
<DT><A name="JHSFA"><B>JHSFA(Rc_word, PJHSArray)</B></A> // <A href="JudyHS_funcs_3.htm#JudyHSFreeArray">JudyHSFreeArray()</A></DT>
<DD>
Given a pointer to a JudyHS array (<B>PJHSArray</B>), free the entire array.
<P>
Return <B>Rc_word</B> set to the number of bytes freed and <B>PJHSArray</B> set to NULL.
<!----------------->
<P>
<DT><A name="ERRORS"><B>ERRORS:</B> See: </A><A href="Judy_3.htm#ERRORS">Judy_3.htm#ERRORS</A></DT>
<DD>
<P>
<DT><B>EXAMPLES</B></DT>
<DD>
Show how to program with the JudyHS macros. This program will print
duplicate lines and their line number from <I>stdin</I>.
<P><PRE>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <Judy.h>
// Compiled:
// cc -O PrintDupLines.c -lJudy -o PrintDupLines
#define MAXLINE 1000000 /* max fgets length of line */
uint8_t Index[MAXLINE]; // string to check
int // Usage: PrintDupLines < file
main()
{
Pvoid_t PJArray = (PWord_t)NULL; // Judy array.
PWord_t PValue; // Judy array element pointer.
Word_t Bytes; // size of JudyHS array.
Word_t LineNumb = 0; // current line number
Word_t Dups = 0; // number of duplicate lines
while (fgets(Index, MAXLINE, stdin) != (char *)NULL)
{
LineNumb++; // line number
// store string into array
JHSI(PValue, PJArray, Index, strlen(Index));
if (PValue == PJERR) // See ERRORS section
{
fprintf(stderr, "Out of memory -- exit\n");
exit(1);
}
if (*PValue == 0) // check if duplicate
{
Dups++;
printf("Duplicate lines %lu:%lu:%s", *PValue, LineNumb, Index);
}
else
{
*PValue = LineNumb; // store Line number
}
}
printf("%lu Duplicates, free JudyHS array of %lu Lines\n",
Dups, LineNumb - Dups);
JHSFA(Bytes, PJArray); // free JudyHS array
printf("JudyHSFreeArray() free'ed %lu bytes of memory\n", Bytes);
return (0);
}
</PRE>
<!----------------->
<P>
<DT><B>AUTHOR</B></DT>
<DD>
JudyHS was invented and implemented by Doug Baskins after retiring from Hewlett-Packard.
<!----------------->
<P>
<DT><B>SEE ALSO</B></DT>
<DD>
<A href="Judy_3.htm">Judy(3)</A>,
<A href="Judy1_3.htm">Judy1(3)</A>,
<A href="JudyL_3.htm">JudyL(3)</A>,
<A href="JudySL_3.htm">JudySL(3)</A>,
<BR>
<I>malloc()</I>,
<BR>
the Judy website,
<A href="http://judy.sourceforge.net">
http://judy.sourceforge.net</A>,
for further information and Application Notes.
</BODY>
</HTML>
( run in 0.489 second using v1.01-cache-2.11-cpan-39bf76dae61 )