.TA j JudySL - Online Linux Manual PageSection : 3
NAMEJudySL macros - C library for creating and accessing a dynamic array, using a null-terminated string as an Index (associative array)
SYNOPSIS¶.ft B
cc [flags] sourcefiles -lJudy#include <Judy.h>#define MAXLINELEN 1000000 // define maximum string lengthWord_t * PValue; // JudySL array element
uint8_t Index[MAXLINELEN]; // string
int Rc_int; // return value
Word_t Rc_word; // full word return valuePvoid_t PJSLArray = (Pvoid_t) NULL; // initialize JudySL arrayJSLI( PValue, PJSLArray, Index); // JudySLIns()
JSLD( Rc_int, PJSLArray, Index); // JudySLDel()
JSLG( PValue, PJSLArray, Index); // JudySLGet()
JSLFA(Rc_word, PJSLArray); // JudySLFreeArray()
JSLF( PValue, PJSLArray, Index); // JudySLFirst()
JSLN( PValue, PJSLArray, Index); // JudySLNext()
JSLL( PValue, PJSLArray, Index); // JudySLLast()
JSLP( PValue, PJSLArray, Index); // JudySLPrev()
¶.fi
DESCRIPTION
A JudySL array is the equivalent of a sorted set of strings, each associated with a Value (word). A Value is addressed by an Index (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 ¶void * JudySLArray["Toto, I don't think we're in Kansas any more"];
¶.fiA JudySL array is allocated with a NULL pointer¶Pvoid_t PJSLArray = (Pvoid_t) NULL;
¶.fi
As with an ordinary array, there are no duplicate indexes (strings)
in a JudySL array.Using the macros described here, rather than the
JudySL function calls,
the default error handling sends a
message to the standard error and terminates the program with
exit(1).
JSLI(PValue, PJSLArray, Index) // JudySLIns()
Insert an Index string and Value in the JudySL array PJSLArray. If the Index is successfully inserted, the Value is initialized to 0. If the Index was already present, the Value is not modified. Return PValue pointing to Index's Value. Your program must use this pointer to modify the Value, for example: ¶*PValue = 1234;
¶.fiNote:
JSLI() and JSLD reorganize the JudySL array.
Therefore, pointers returned from previous JudySL calls become
invalid and must be reacquired.
JSLD(Rc_int, PJSLArray, Index) // JudySLDel()
Delete the specified Index/Value pair (array element) from the JudySL array. Return Rc_int set to 1 if successful. array and it was previously inserted. Return Rc_int set to 0 if Index was not present.
JSLG(PValue, PJSLArray, Index) // JudySLGet()Get the pointer to Index's Value. Return PValue pointing to Index's Value. Return PValue set to NULL if the Index was not present.
JSLFA(Rc_word, PJSLArray) // JudySLFreeArray()Given a pointer to a JudySL array (PJSLArray), free the entire array (much faster than using a JSLN(), JSLD() loop.) Return Rc_word set to the number of bytes freed and PJSLArray set to NULL.
JudySL Search FunctionsThe JudySL search functions allow you to search for indexes in the array. You may search inclusively or exclusively, in either forward or reverse directions. If successful, Index is returned set to the found index, and PValue is returned set to a pointer to Index's Value. If unsuccessful, PValue is returned set to NULL, and Index contains no useful information. PValue must be tested for non-NULL prior to using Index, since a search failure is possible. Note: To accomodate all possible returns, the Index buffer must be at least as large as the largest string stored in the array.
JSLF(PValue, PJSLArray, Index) // JudySLFirst()Search (inclusive) for the first index present that is equal to or greater than the passed Index string. (Start with a null string to find the first index in the array.) JSLF() is typically used to begin a sorted-order scan of the valid indexes in a JudySL array. ¶uint8_t Index[MAXLINELEN];
strcpy (Index, "");
JSLF(PValue, PJSLArray, Index);
¶.fi
JSLN(PValue, PJSLArray, Index) // JudySLNext()
Search (exclusive) for the next index present that is greater than the passed Index string. JSLN() is typically used to continue a sorted-order scan of the valid indexes in a JudySL array, or to locate a "neighbor" of a given index.
JSLL(PValue, PJSLArray, Index) // JudySLLast()Search (inclusive) for the last index present that is equal to or less than the passed Index string. (Start with a maximum-valued string to look up the last index in the array, such as a max-length string of 0xff bytes.) JSLL() is typically used to begin a reverse-sorted-order scan of the valid indexes in a JudySL array.
JSLP(PValue, PJSLArray, Index) // JudySLPrev()Search (exclusive) for the previous index present that is less than the passed Index string. JSLP() is typically used to continue a reverse-sorted-order scan of the valid indexes in a JudySL array, or to locate a "neighbor" of a given index.
ERRORS: See: Judy_3.htm#ERRORS
EXAMPLE of a string sort routine¶#include <stdio.h>
#include <Judy.h>#define MAXLINE 1000000 // max string (line) lengthuint8_t Index[MAXLINE]; // string to insertint // Usage: JudySort < file_to_sort
main()
{
Pvoid_t PJArray = (PWord_t)NULL; // Judy array.
PWord_t PValue; // Judy array element.
Word_t Bytes; // size of JudySL array. while (fgets(Index, MAXLINE, stdin) != (char *)NULL)
{
JSLI(PValue, PJArray, Index); // store string into array
if (PValue == PJERR) // if out of memory?
{ // so do something
printf("Malloc failed -- get more ram\n");
exit(1);
}
++(*PValue); // count instances of string
}
Index[0] = ' '; // start with smallest string.
JSLF(PValue, PJArray, Index); // get first string
while (PValue != NULL)
{
while ((*PValue)--) // print duplicates
printf("%s", Index);
JSLN(PValue, PJArray, Index); // get next string
}
JSLFA(Bytes, PJArray); // free array fprintf(stderr, "The JudySL array used %lu bytes of memory\n", Bytes);
return (0);
}
¶.fi
AUTHOR
Judy was invented by Doug Baskins and implemented by Hewlett-Packard.
SEE ALSOJudy(3), Judy1(3), JudyL(3), JudyHS(3),
malloc(),
the Judy website, http://judy.sourceforge.net, for further information and Application Notes. 0
Johanes Gumabo
Data Size : 29,108 byte
man-JSLF.3Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 4 / 164,615
Visitor ID : :
Visitor IP : 18.117.119.34 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|J___SLD.3|3|TA|.TA j
) (rof_nr_x|149|J___SLD.3|206|\n");| printf("Malloc failed -- get more ram\\n");
) (rof_nr_x|149|J___SLD.3|221|\n", Bytes);| fprintf(stderr, "The JudySL array used %lu bytes of memory\\n", Bytes);
)