Re: [fpc-pascal] fgl unit bug in generic class TFPGMap

2014-10-27 Thread leledumbo
> But a map should not need any call to Sort, because it's the map's task 
to organize its data structure in such a way that Find does work as it 
should. 

TFPGMap seems to inherit its original sin: as long as it's a container that
implements key-value based storage, then it's a map. And there it is,
TFPGMap is created as a descendant of TFPSMap which in turn is a descendant
of TFPSList. The last one is the source of Sort/IndexOf/whatever that
normally doesn't apply to map containers. Sometimes I find it useful,
though. So I don't really have a problem with it.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/fgl-unit-bug-in-generic-class-TFPGMap-tp5720282p5720400.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fgl unit bug in generic class TFPGMap

2014-10-27 Thread Flávio Etrusco
On Mon, Oct 27, 2014 at 3:45 PM, Sven Barth  wrote:
> Am 26.10.2014 05:51, schrieb Flávio Etrusco:
>
>> On Fri, Oct 3, 2014 at 12:42 PM, Dennis Poon 
>> wrote:
>>>
>>> I think I found a bug in TFPGMap.
>>> Hope some of you can verify it.
>>>
>>> The bug seems to relate to the binary search used in the method "FIND"
>>> but
>>> it does not occur for all string key values or at all capacity of the
>>> map.
>>> Seems only occur at the second item added and when it is certain string
>>> values.
>>>
>>> I tried to debug it but cannot step into the codes of fgl unit so cannot
>>> find the cause.
>>>
>>> Please help.
>>>
>>> Dennis
>>>
>>> =
>>> unit Unit1;
>>
>> (...)
>>>
>>>TMapOfObjects=class(specialize TFPGMap < String, TObject> )
>>
>> (...)
>>
>> I don't see any calls to 'Sort' or 'Sorted' in your code. 'Find', as
>> you note, does a binary search thus expects the items to be sorted.
>> You can also use 'IndexOf' instead.
>
> But a map should not need any call to Sort, because it's the map's task to
> organize its data structure in such a way that Find does work as it should.
>
> Regards,
> Sven

That's my opinion too, I just replied based on the source code.
Actually I had written some comments WRT that in my reply but removed
it before sending because I don't know the history of the component. I
was going to say something like: it's very unfortunate that the "most
discoverable" map for FPC is a simple list of pairs and doesn't have
clear/standard map API, and instead exposes its guts.
Maybe Find should call IndexOf if Sorted = False for now?

Regards,
Flávio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fgl unit bug in generic class TFPGMap

2014-10-27 Thread Sven Barth

Am 26.10.2014 05:51, schrieb Flávio Etrusco:

On Fri, Oct 3, 2014 at 12:42 PM, Dennis Poon  wrote:

I think I found a bug in TFPGMap.
Hope some of you can verify it.

The bug seems to relate to the binary search used in the method "FIND" but
it does not occur for all string key values or at all capacity of the map.
Seems only occur at the second item added and when it is certain string
values.

I tried to debug it but cannot step into the codes of fgl unit so cannot
find the cause.

Please help.

Dennis

=
unit Unit1;

(...)

   TMapOfObjects=class(specialize TFPGMap < String, TObject> )

(...)

I don't see any calls to 'Sort' or 'Sorted' in your code. 'Find', as
you note, does a binary search thus expects the items to be sorted.
You can also use 'IndexOf' instead.
But a map should not need any call to Sort, because it's the map's task 
to organize its data structure in such a way that Find does work as it 
should.


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] how do I play mp3 files with Free Pascal?

2014-10-27 Thread Marco van de Voort
In our previous episode, Dennis Poon said:
> I can use the windows MMSystem unit but it only plays .wav file.
> How do I play .mp3 file?

I thought that using mcisendstring one could play all registered codecs.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] how do I play mp3 files with Free Pascal?

2014-10-27 Thread Reinier Olislagers
On 27/10/2014 13:34, Dennis Poon wrote:
> I can use the windows MMSystem unit but it only plays .wav file.
> How do I play .mp3 file?

Search the wiki for multimedia/audio libraries.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] how do I play mp3 files with Free Pascal?

2014-10-27 Thread Dennis Poon

I can use the windows MMSystem unit but it only plays .wav file.
How do I play .mp3 file?

Dennis
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal