[nem-pl] Komparatory w drzewach
Michal Moskal
malekith at pld-linux.org
Thu Jan 15 17:48:45 CET 2004
On Thu, Jan 15, 2004 at 05:34:07PM +0100, "Paweł W. Olszta" wrote:
> Oj oj, Łukasz ma rację. Żyjemy w świecie obiektów, jak bardzo by nas to
> nie bolało. Interfejsy są bardzo efektywne -- metody wirtualne
> przechowywane są w końcu tylko w jednej kopii. Przekazywanie komparatora
> jako argumentu, to dodatkowy push i pop co jakiś czas -- zupełnie bez sensu.
>
> Mamy interfejs System.IComparable. Implementuje go np. System.String i
> System.Int32. Wystawia on nam metodę:
>
> [C#]
> int CompareTo(
> object obj
> );
>
> Parameters
> obj -- An object to compare with this instance.
>
> Return Value
> A 32-bit signed integer that indicates the relative order of the
> comparands. The return value has these meanings:
>
> Value Meaning
> Less than zero This instance is less than obj.
> Zero This instance is equal to obj.
> Greater than zero This instance is greater than obj.
>
> Exceptions
> ArgumentException obj is not the same type as this instance.
>
> I chyba nic więcej nie potrzebujemy?
Potrzebujemy, System.Collections.Generic.IComparableTo.
--
: Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv
: When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h
More information about the devel-pl
mailing list