Boost logo

Boost :

From: Spencer Collyer (spencer_at_[hidden])
Date: 2006-04-26 14:19:48


I'd like to canvas opinions on whether it is worth submitting a class
I've developed to Boost.

It is a policy-based sparse array class. I'm aware there is a
sparse_vector class in the uBLAS library, but when I looked at it it
didn't seem to offer the degree of flexibility I needed, so I developed
my own. Like a lot of things, it grew a little during development, but
I've tried to keep the interface as close to std::vector as seemed
sensible.

To try and make it as flexible as possible, I've implemented it using
four policies, as follows:

bounds:
This determines what the bounds on the sparse_array are, and how values
that exceed them are handled. For example, the 'unbounded' policy allows
virtually any positive value of the subscript type to be used, 'bounded'
only allows values within the (compile-time specified) max value and
throws if a subscript exceeding this is given, while 'clamped' makes such
value equal to the max value.

iterator:
This determines how the limits on iterators are defined. So it is
possible to specify that iteration should be over the whole range of the
sparse_array, or that it should only be from the lowest assigned
subscript to the highest assigned subscript.

value:
This policy is currently used to define the default value for unassigned
elements of the sparse_array, and also to determine how default values
are handled in cases such as assigning from one sparse_array to another.

storage:
This allows the user to specify how the underlying storage for the
sparse_array is handled. Currently I only have one policy defined
(std_map, which unsurprisingly uses a std::map for the storage), but
policies to use hash maps or something akin to Loki's AssocVector could
be easily defined.

I'd like to know if people would be interested in seeing such a class in
Boost before I plunge into writing up the documentation (which is
currently pretty sparse, and consists primarily of the comments in the
code) and finishing off all the test programs prior to submission.

-- 
<<< Eagles may soar, but weasels don't get sucked into jet engines >>>
5:43pm up 39 days 5:16, 19 users, load average: 0.06, 0.05, 0.04
Registered Linux User #232457 | LFS ID 11703

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk