chiark / gitweb /
@@@ much mess, mostly manpages
[mLib] / struct / hash.3.in
similarity index 80%
rename from struct/hash.3
rename to struct/hash.3.in
index fdde662a7309fb2c2c91650cd654fead46aba0a6..41258fa701f181c4667359d40082246c36a1a20f 100644 (file)
@@ -1,37 +1,34 @@
 .\" -*-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
@@ -39,12 +36,18 @@ hash \- low-level hashtable implementation
 .\" @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
@@ -74,7 +77,10 @@ hash \- low-level hashtable implementation
 .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.
@@ -91,7 +97,10 @@ A complete hashtable implementation will need to take the above
 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
@@ -140,7 +149,10 @@ It is up to the high-level implementation to insert items into the list.
 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:
@@ -165,6 +177,7 @@ The implementation presented here is simple but relatively bad.  The
 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
@@ -206,6 +219,7 @@ void item_destroytab(item_table *t)
 }
 .VE
 .sp -1
+.
 .SS "Searching, adding and removing"
 Items must be searched for and added by hand.
 .PP
@@ -291,6 +305,7 @@ Removal of items is more straightforward.  The function
 .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
@@ -316,8 +331,16 @@ is 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 --------------------------------------------------