The BLAH Reference Manual.
0.95
- Author:
- Ingo Schröder
Kilian A. Foth
Michael Daum
This is the reference manual for the BLAH library for the C programming language. BLAH stands for bitstrings, lists, arrays and hashes --- admittedly a poorly chosen giving the set of container data types most usually used. Actually there are more data types than these but who cares if the name is funky enuf.
The BLAH library is copyright by The CDG Team; it is distributed under the GNU General Publice License Version 2. You should have received a copy of the GPL with the software.
The maintainers of this software can be contacted at the following email address:
blah@nats.informatik.uni-hamburg.de
The BLAH library is installed as both shared and static versions of the library by default. In order to use it your C code must include the header file
For instance, if you installed the header file in a system directory, a minimal C program might look as follows:
#include <stdio.h>
#include <blah.h>
int main(int argc, char **argv)
{
List squares=listNew();
int i;
for (i=0; i<100; i++)
{
squares=listPrependElement(squares, (Pointer)(i*i));
}
printf("42th square is %d\n", (int)listNthElement(squares, 42));
listDelete(squares);
}
You have to link against the BLAH library as well as the math library to create a binary:
$ gcc -o blah-example -lblah -lm blah-example.c
$ ./blah-example
42th square is 3364
$
The BLAH library defines the following container data types:
- Arrays: An array stores information that is accessed using a number of indices. Arrays usually have two or more dimensions. The number of dimensions as well as the size of each dimension must be provided at creation time of the array and stay fixed. The required time to access a specific information given the corresponding indices is constant; the memory is proportional to the product of all dimension sizes.
- BitStrings: A bitstring stores a sequence of Booleans. The design emphasis is on memory efficiency.
- ByteVectors: A bitvector also stores a sequence of Booleans. However, one byte is used to store a single Boolean. This data type is more time efficient than a bitstring.
- Hashtables: A hashtable stores key-value pairs. The key is used to access the actual information in the value. Access time is (almost) constant for arbitrary sizes of the hashtable and arbitrary keys.
- Lists: A list stores a sequence of objects. Access to the head of the list is efficiently possible while in general access to an arbitrary object requires linear time.
- ListAgenda: An agenda is created by sorting the items according to priority using a simple linked list as its storage medium.
- Memory: Some basic Operations with the memory are done in this module.
- Primes: Prime is a module that makes use of Rabin's Probablistic Primetest-Algorithm for generating the prime numbers equal to the Hash table entries.
- Ringbuffers: It is similar to the vector that stores a series of objects, though the head and the tail are attached inorder to enhance cyclic operations.
- Strings: Strings in C are represented by arrays of characters. The end of the string is marked with a special character, the null character, which is simply the character with the value 0. Whenever we write a string, enclosed in double quotes, C automatically creates an array of characters for us, containing that string, terminated by the NULL character.
- TreeAgenda: An agenda is created by sorting the items according to the order of the priority using an unbalanced binary tree.
- Vectors: A vector stores objects at a given index. The size of the vector is linear in the largest used index. Time to access an object given the index is constant.
BLAH 0.95 (20 Oct 2004)