.\" -*-nroff-*-
-.de VS
-.sp 1
-.RS
-.nf
-.ft B
-..
-.de VE
-.ft R
-.fi
-.RE
-.sp 1
-..
-.de hP
-.IP
-.ft B
-\h'-\w'\\$1\ 'u'\\$1\ \c
-.ft P
-..
-.ie t \{\
-. ds o \(bu
-. de VP
-. sp .4v
-..
-\}
-.el \{\
-. ds o o
-. de VP
-. sp
-..
-\}
-.TH hash 3 "2 August 1999" "Straylight/Edgeware" "mLib utilities library"
-.SH "NAME"
-hash \- low-level hashtable implementation
+.\"
+.\" Manual for hash table framework
+.\"
+.\" (c) 1999, 2001, 2003, 2005, 2009, 2023, 2024 Straylight/Edgeware
+.\"
+.
+.\"----- Licensing notice ---------------------------------------------------
+.\"
+.\" This file is part of the mLib utilities library.
+.\"
+.\" mLib is free software: you can redistribute it and/or modify it under
+.\" the terms of the GNU Library General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or (at
+.\" your option) any later version.
+.\"
+.\" mLib is distributed in the hope that it will be useful, but WITHOUT
+.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
+.\" License for more details.
+.\"
+.\" You should have received a copy of the GNU Library General Public
+.\" License along with mLib. If not, write to the Free Software
+.\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+.\" USA.
+.
+.\"--------------------------------------------------------------------------
+.so ../defs.man \" @@@PRE@@@
+.
+.\"--------------------------------------------------------------------------
+.TH hash 3mLib "2 August 1999" "Straylight/Edgeware" "mLib utilities library"
.\" @hash_create
.\" @hash_destroy
.\" @hash_bin
.\" @hash_remove
.\" @hash_mkiter
.\" @hash_next
-.\"
+.
.\" @HASH_BIN
.\" @HASH_MKITER
.\" @HASH_NEXT
-.\"
+.
+.\"--------------------------------------------------------------------------
+.SH "NAME"
+hash \- low-level hashtable implementation
+.
+.\"--------------------------------------------------------------------------
.SH "SYNOPSIS"
+.
.nf
.B "#include <mLib/hash.h>"
.PP
.BI "void HASH_MKITER(hash_iter *" i ", hash_table *" t );
.BI "void HASH_NEXT(hash_iter *" i ", " b );
.fi
+.
+.\"--------------------------------------------------------------------------
.SH "OVERVIEW"
+.
The
.B hash
functions provide the basis for an extensible hashtable implementation.
decisions. If you just want a prepackaged solution, see
.BR sym (3)
which provides one.
+.
+.\"--------------------------------------------------------------------------
.SH "IMPLEMENTATION DETAILS"
+.
Each item in the hashtable is assigned a 32-bit integer
.IR hash :
a number computed somehow from the item's data such that two items which
The hash for this item. This must be the full 32-bit hash for the
current item. It is used during hashtable expansion to determine which
bin an item should be moved to.
+.
+.\"--------------------------------------------------------------------------
.SH "FUNCTIONALITY PROVIDED"
+.
This section describes the functions and macros provided for building
hashtables. Code examples are given throughout. They assume the
following definitions:
source file
.B sym.c
presents a more realistic example, but is rather more complex.
+.
.SS "Initialization and finalization"
An empty hashtable is initialized by calling
.B hash_create
}
.VE
.sp -1
+.
.SS "Searching, adding and removing"
Items must be searched for and added by hand.
.PP
.B hash_remove
will unlink a given item from its bin list, after which point it is safe
to remove.
+.
.SS "Iteration"
Iteration allows code to be performed on all the items in a hashtable.
This is done using an
which is updated to contain the address of the next item.
.PP
The finalization code above contained an example of iteration.
+.
+.\"--------------------------------------------------------------------------
.SH "SEE ALSO"
+.
.BR sym (3),
.BR mLib (3).
+.
+.\"--------------------------------------------------------------------------
.SH "AUTHOR"
+.
Mark Wooding, <mdw@distorted.org.uk>
+.
+.\"----- That's all, folks --------------------------------------------------