Have you ever thought about well balanced binary trees that are compiled into your program? With fsss you got it. Now you don't have to add elements into binary tree or sort your data at program startup to speed up search. Fsss does it for you.

Fast & Simple Structure Search

Fsss is the utility that generates .c and .h files with already sorted keys and values. Keys are strings, values are structures. All you need is to prepare input file in very simple format:

       "key1" "key1_alias1" {field1, field2, fieldn}
       "key2"  {field1, field2, fieldn}
       "key3" "key3_alias1" "key3_alias3"  {field1, field2, fieldn}

Then you need to execute fsss specifying input file, structure type and header file where the structure is declared. For example:

       $ cat > rgb.fsss
       "red" {255, 0, 0}
       "green" {0, 255, 0}
       "blue" {0, 0, 255}

       $ fsss rgb color.h rgb.fsss

Generated .c file contains function for fast searchig. It takes one argument - string to search and returns pointer to the found structure.

Now, inside your program you can do the following:

       #include "rgb.h"

       struct rgb *data;

       data = fsss_rgb_search("red");

The best way to get familiar with it is to try it yourself. Download, compile and install it now. Archive contains manual page with the full information about fsss and the latest supported features.

Happy searching!

Ukrainian OpenBSD User Group
Get Firefox

Copyright © 2006-2016, Alexey Vatchenko. All rights reserved.
Designed by Vladimir Mostovoy.