[Lemon-devel] General map utilities

Kovács Péter kpeter at inf.elte.hu
Fri Jan 4 09:19:51 CET 2008


Hi,

I would like to comment Alpar's letter (22 Dec 2007) about map utilities.

 > I found however, that there are a lot of special purpose tools
 > in /lemon/maps.h which are of very little use in general. For example
 > there are several classes which acts as a writable bool map and does
 > something special when a 'true' value is assigned to a key. These
 > seems to be a bit superfluous for me, not to mention their messy and
 > incomplete documentation.

I don't think so.

I think these classes can be used many times, since these purposes are 
really general and often needed. Using these classes makes 
implementation easier and results more understandable code. There are 
good examples for this in the documentation (InserterBoolMap, 
BackInserterBoolMap, StoreBoolMap, etc.).

I do not support replacing them with a general class that uses a 
functor. I think writing a functor and using it with this class would be 
as complicated as implementing the required map type itself, since it is 
very simple. I would choose this way.

Similarly AddMap, SubMap, MulMap, DivMap should not be removed just 
because they can be easily implemented using CombineMap.

For the misleading class namings the following are my suggestions:
   IntegerMap -> RangeMap
   SubMap -> DifferenceMap or DiffMap
   SimpleMap -> WrapMap or WrapperMap
   SimpleWriteMap -> WrapWriteMap or WrapperWriteMap

Regards,
Peter

> Hi,
> 
> I ported the general map utilities (lemon/maps.h and dependencies) into
> hg and somewhat revised its doc. You can find it in my repository:
> 
> http://lime.cs.elte.hu/~alpar/hgwebdir.cgi/lemon/rev/61bf7f22a6d6
> 
> (
> you can get it either by cloning this version of my repo:
> 
> hg clone -r 61bf7f22a6d6
> http://lime.cs.elte.hu/~alpar/hgwebdir.cgi/lemon
> 
> or by cloning the full repo then updating to this version:
> 
> hg clone http://lime.cs.elte.hu/~alpar/hgwebdir.cgi/lemon tmp-repo
> cd tmp-repo
> hg up  -r 61bf7f22a6d6
> )
> 
> I found however, that there are a lot of special purpose tools
> in /lemon/maps.h which are of very little use in general. For example
> there are several classes which acts as a writable bool map and does
> something special when a 'true' value is assigned to a key. These seems
> to be a bit superfluous for me, not to mention their messy and
> incomplete documentation.
> My suggestion would be to replace all these classes with a single one
> that is able to apply a
> void f(const Key &k)
> or
> void f(const Key &k, bool val)
> type functor for true/false or all assignments. What is your opinion?
> 
> There are other inconsistences and probably wrong namings in
> lemon/maps.h, I marked them with a \todo doxygen command. Please comment
> them.
> 
> All the best,
> Alpar
> 
> 



More information about the Lemon-devel mailing list