|
Boost : |
From: Kevin Atkinson (kevin_at_[hidden])
Date: 2002-11-09 20:06:48
If people are interested I would like to present several possible
additions to the Boost library. I will be willing to answer questions
about my code but won't be willing to modify my code to boost standards as
I simply don't have the time.
They are:
A generic hash table based on the SGI hash table with similar semantics
from which the standard hash_* classes can be created. The main
advantage to the generic table as compared to the hash_* classes is
that it allows the key to be part of the value rather than having
to use a pair which can be redundant and waste space.
An Open Address hash table which uses a vector like object to store its
data. The main advantage of this hash table is that it is compact
space wise. It also uses a provided vector like object for its storage
so that the entire table can easily be written to disk and read back
in with out having to marshall the data in any fashion.
A special Error handling device, PosibErr<type>, that will make
sure that an error is properly handled. It is expected to be
used as the return type of the function It will automatically
convert to the "normal" return type however if the normal
returned type is accessed and there is an "unhandled" error
condition it will abort It will also abort if the object is
destroyed with an "unhandled" error condition. This includes
ignoring the return type of a function returning an error
condition. An error condition is handled by simply checking for
the presence of an error, calling ignore, or taking ownership of
the error.
It is better than simply returning an error code because it forces you
to handle the error. Although less convent than exceptions it is more
effect and easier to debug since it does not unwind the stack.
Generic smart points which deep copy semantics where the copy,
and destructor functions can be user defined.
Enumeration: An efficient way to iterate through elements much
like a forward iterator. The at_end method is a convince method
as enumerations will return a null pointer or some other sort of
special end state when they are at the end.
Unlike an iterator iterating through x elements on a list can be
done in x function calls while an iterator will require 3*x.
function calls.
Example of emulator usage
const char * word;
while ( (word = elements->next()) != 0) { // one function call
cout << word << endl;
}
And an iterator
iterator i = container->begin();
iterator end = container->end();
while (i != end) { // comparison, one function call
cout << *i << endl; // deref, total of two function calls
++i; // increment, total of three function calls.
}
Normally all three calls are inline so it doesn't really matter
but when the container type is not visible there are not inline
and probably even virtual.
If anyone is interested in any of these let me know the best way to
present them and I will do so. If not no big deal.
-- http://kevin.atkinson.dhs.org
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk