1Judy::HS(3)           User Contributed Perl Documentation          Judy::HS(3)
2
3
4

NAME

6       Judy::HS - Efficiet string to integer map
7

SYNOPSIS

9       Removing duplicates from a list using sugar
10
11         use Judy::HS qw( Duplicates Free );
12
13         my $judy;
14         for (qw( d d c a d b c b a b a c )) {
15           print "$_\n" if ! Duplicates( $judy, $_ );
16         }
17         printf "Freed %d bytes\n", Free( $judy );
18
19       Remove duplicates with less sugar
20
21         use Judy::HS qw( Set Get Free );
22
23         my $judy;
24         for (qw( d d c a d b c b a b a c )) {
25             my ( undef, $value ) = Get( $judy, $_ );
26             if ( ! $value ) {
27                 Set( $judy, $_, 1 );
28                 print "$_\n";
29             }
30         }
31         printf "Freed %d bytes\n", Free( $judy );
32

DESCRIPTION

34       Judy::HS is an equivalent to a hash of integers. The keys are all
35       strings, the values are integers. JudyHS is a hybrid using the best
36       capabilities of hashing and Judy methods. JudyHS does not have a poor
37       performance case where knowledge of the hash algorithm can be used to
38       degrade the performance.
39
40       Since JudyHS is based on a hash method, Keys are not stored in any
41       particular order. Therefore the "First()", "Next()", "Prev()" and
42       "Last()" neighbor search functions are not practical.  To enumerate a
43       Judy::HS object, see <http://perlmonks.org/?node_id=733140>. This is
44       not supported but it works.
45
46       The hallmark of JudyHS is speed with scalability, but memory efficiency
47       is excelleny. The speed is very competitive with the best hashing
48       methods. The memory efficiency is similar to a linked list of the same
49       Keys and Values. JudyHS is designed to scale from 0 to billions of
50       Keys.
51
52       Nothing special is required to allocate a Judy::HS array. Just start
53       using it.
54
55           my $judy;
56           if ( Get( $judy, 'omg' ) ) {
57               Set( $judy, 'zomg', 42 );
58               ...
59           }
60
61       As with an ordinary array, there are no duplicate keys in a Judy::HS
62       array.
63

DATA TYPES

65   $Judy - Judy::HS array
66   $Key - a string with no null characters
67   $Value - integer
68   $PValue - pointer to integer

BASIC FUNCTIONS

70   $PValue = Set( $Judy, $Key, $Value )
71       Insert/set a $Key and $Value into $Judy.
72
73       Returns $PValue pointing to the stored $Value. Your program can use
74       this pointer to modify the stored $Value until the next "Set()",
75       "Delete()", "Free()". Example:
76
77         use Judy::Mem qw( Peek );
78         use Judy::HS qw( Set );
79
80         $pvalue = Set( $judy, "al\0ha", 42 );
81         printf "al\\0ha=%d\n", Peek( $pvalue );
82
83       Note: "Set()" and Delete can reorganize the JudyHS array. Therefore,
84       pointers returned from previous JudyHS calls become invalid and must be
85       re-acquired (using Get()).
86
87   bool = Delete( $Judy, $Key )
88       Delete the specified $Key/$Value pair from Judy::HS. Returns true if
89       the element was removed, false otherwise.
90
91   ( $PValue, $Value ) = Get( $Judy, $Key )
92       Get $Key's $Value. If $Key exists in $Judy, return $PValue pointing to
93       $Key's $Value and $Value in a list. Return nothing if $Key isn't
94       present.
95

SEARCH FUNCTIONS

97       There are no search functions and no endorsed methods for enumerating
98       the contents of Judy::HS. It's possible though. See
99       <http://perlmonks.org/?node_id=733140>.
100

UTILITY FUNCTIONS

102   bytes = Free( $Judy )
103       Frees an entire Judy::HS array. $Judy is set to 0.
104
105   bytes = MemUsed( $Judy )
106       Returns the size of a Judy::HS array. This implementation is not
107       supplied by libJudy.
108

MULTIDIMENSIONAL Judy::HS

110       See Judy.
111

ERRORS & WARNINGS

113       See Judy.
114

AUTHOR

116       See Judy.
117
118
119
120perl v5.28.0                      2018-07-14                       Judy::HS(3)
Impressum