Re: [lazarus] HashMap
On Fri, Aug 18, 2006 at 12:01:09AM +, Albert Zeyer wrote: > The SDL port is very interesting. All data structures I missed are > there. I will take a deeper look tomorrow, but I think, this is what I > want. See my notes in the forward of the doc. Performance and footprint might become a problem. _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
The SDL port is very interesting. All data structures I missed are there. I will take a deeper look tomorrow, but I think, this is what I want. Albert Am Donnerstag, den 17.08.2006, 12:02 +0200 schrieb Burkhard Carstens: Am Donnerstag, 17. August 2006 13:16 schrieb Albert Zeyer: > Which one do you mean? I only find there a few special lists. > > But I need an implementation of a map (key elements map to some > data), implemented with B-trees or similar (the key elements need to > be hashed for this), like hash_map in STL. In my case, I don't need a > special hash function because my key elements are object pointers. > > Albert. 1. There has been something in the fpc-announce mailing list about "PascalAdt". I just have no idea, where to find the sources. 2. There is something in fpcprojects, that might be interesting. Docs: http://www.stack.nl/~marcov/decal.pdf Sources: www.freepascal.org/cgi-bin/viewcvs.cgi/contrib/ decal/?root=fpcprojects&rev=814 regards Burkhard _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
Thank you, this is a good base. But I need it a little bit more abstract. Mainly, I also need reference counting on the objects (interfaces now) I saved there. Yes, I can call _AddRef and _Release by myself, but this doesn't look very nice. And in future, I want to use other sort of key elements (eg strings). It would be nice if I can select any hash-function (a function, which maps my object to an integer) for my key objects so that I can use everything as keys. The code has to be extended a little bit to handle collisions. If I find the time, I can do this. And Burkhard is right, this should be merged into the FPL tree. Albert Am Donnerstag, den 17.08.2006, 11:25 +0200 schrieb Mattias: On Thu, 17 Aug 2006 11:16:58 + Albert Zeyer <[EMAIL PROTECTED]> wrote: > Which one do you mean? I only find there a few special lists. > > But I need an implementation of a map (key elements map to some data), > implemented with B-trees or similar (the key elements need to be > hashed for this), like hash_map in STL. In my case, I don't need a > special hash function because my key elements are object pointers. lcl/avglvltree.pas has TPointerToPointerTree Usage: Tree:=TPointerToPointerTree.Create; Tree[SomePointer]:=SomeData; Value:=Tree[SomePointer]; Mattias > > Albert. > > > Am Donnerstag, den 17.08.2006, 08:08 +0200 schrieb Michael Van > Canneyt: > > > > > On Thu, 17 Aug 2006, Albert Zeyer wrote: > > > > > Hi there. > > > > > > Is there any HashMap-implementation in the units of FPC? I didn't > > > find one. Is an implemenentation missing till now? How can you > > > life without it? :) > > > > There is a hash implementation in the contnrs unit, but I don't > > know if this is suitable for your purposes. > > > > Michael. > > > > _ > > To unsubscribe: mail [EMAIL PROTECTED] with > > "unsubscribe" as the Subject > >archives at http://www.lazarus.freepascal.org/mailarchives > > _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
On Thu, 17 Aug 2006 13:03:41 +0200 Burkhard Carstens <[EMAIL PROTECTED]> wrote: > Am Donnerstag, 17. August 2006 11:25 schrieb Mattias: > > On Thu, 17 Aug 2006 11:16:58 + > > > > Albert Zeyer <[EMAIL PROTECTED]> wrote: > > > Which one do you mean? I only find there a few special lists. > > > > > > But I need an implementation of a map (key elements map to some > > > data), implemented with B-trees or similar (the key elements need > > > to be hashed for this), like hash_map in STL. In my case, I don't > > > need a special hash function because my key elements are object > > > pointers. > > > > lcl/avglvltree.pas has TPointerToPointerTree > > Usage: > > Tree:=TPointerToPointerTree.Create; > > Tree[SomePointer]:=SomeData; > > Value:=Tree[SomePointer]; > > Nice thing! Looks like there is no dependency on lcl, so couldn't this > be moved to rtl/fcl ? Yes. Maybe we should add a Delete or Undefine method. Mattias _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
Mattias wrote: On Thu, 17 Aug 2006 11:16:58 + Albert Zeyer <[EMAIL PROTECTED]> wrote: Which one do you mean? I only find there a few special lists. But I need an implementation of a map (key elements map to some data), implemented with B-trees or similar (the key elements need to be hashed for this), like hash_map in STL. In my case, I don't need a special hash function because my key elements are object pointers. lcl/avglvltree.pas has TPointerToPointerTree Usage: Tree:=TPointerToPointerTree.Create; Tree[SomePointer]:=SomeData; Value:=Tree[SomePointer]; There is also a map implementation based on avgltrees in lcl/maps Marc _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
Am Donnerstag, 17. August 2006 11:25 schrieb Mattias: > On Thu, 17 Aug 2006 11:16:58 + > > Albert Zeyer <[EMAIL PROTECTED]> wrote: > > Which one do you mean? I only find there a few special lists. > > > > But I need an implementation of a map (key elements map to some > > data), implemented with B-trees or similar (the key elements need > > to be hashed for this), like hash_map in STL. In my case, I don't > > need a special hash function because my key elements are object > > pointers. > > lcl/avglvltree.pas has TPointerToPointerTree > Usage: > Tree:=TPointerToPointerTree.Create; > Tree[SomePointer]:=SomeData; > Value:=Tree[SomePointer]; Nice thing! Looks like there is no dependency on lcl, so couldn't this be moved to rtl/fcl ? regards, Burkhard _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
Am Donnerstag, 17. August 2006 13:16 schrieb Albert Zeyer: > Which one do you mean? I only find there a few special lists. > > But I need an implementation of a map (key elements map to some > data), implemented with B-trees or similar (the key elements need to > be hashed for this), like hash_map in STL. In my case, I don't need a > special hash function because my key elements are object pointers. > > Albert. 1. There has been something in the fpc-announce mailing list about "PascalAdt". I just have no idea, where to find the sources. 2. There is something in fpcprojects, that might be interesting. Docs: http://www.stack.nl/~marcov/decal.pdf Sources: www.freepascal.org/cgi-bin/viewcvs.cgi/contrib/ decal/?root=fpcprojects&rev=814 regards Burkhard _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
On Thu, 17 Aug 2006 11:16:58 + Albert Zeyer <[EMAIL PROTECTED]> wrote: > Which one do you mean? I only find there a few special lists. > > But I need an implementation of a map (key elements map to some data), > implemented with B-trees or similar (the key elements need to be > hashed for this), like hash_map in STL. In my case, I don't need a > special hash function because my key elements are object pointers. lcl/avglvltree.pas has TPointerToPointerTree Usage: Tree:=TPointerToPointerTree.Create; Tree[SomePointer]:=SomeData; Value:=Tree[SomePointer]; Mattias > > Albert. > > > Am Donnerstag, den 17.08.2006, 08:08 +0200 schrieb Michael Van > Canneyt: > > > > > On Thu, 17 Aug 2006, Albert Zeyer wrote: > > > > > Hi there. > > > > > > Is there any HashMap-implementation in the units of FPC? I didn't > > > find one. Is an implemenentation missing till now? How can you > > > life without it? :) > > > > There is a hash implementation in the contnrs unit, but I don't > > know if this is suitable for your purposes. > > > > Michael. > > > > _ > > To unsubscribe: mail [EMAIL PROTECTED] with > > "unsubscribe" as the Subject > >archives at http://www.lazarus.freepascal.org/mailarchives > > _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
Which one do you mean? I only find there a few special lists. But I need an implementation of a map (key elements map to some data), implemented with B-trees or similar (the key elements need to be hashed for this), like hash_map in STL. In my case, I don't need a special hash function because my key elements are object pointers. Albert. Am Donnerstag, den 17.08.2006, 08:08 +0200 schrieb Michael Van Canneyt: On Thu, 17 Aug 2006, Albert Zeyer wrote: > Hi there. > > Is there any HashMap-implementation in the units of FPC? I didn't find > one. Is an implemenentation missing till now? How can you life without > it? :) There is a hash implementation in the contnrs unit, but I don't know if this is suitable for your purposes. Michael. _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] HashMap
On Thu, 17 Aug 2006, Albert Zeyer wrote: > Hi there. > > Is there any HashMap-implementation in the units of FPC? I didn't find > one. Is an implemenentation missing till now? How can you life without > it? :) There is a hash implementation in the contnrs unit, but I don't know if this is suitable for your purposes. Michael. _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives