public int compare(Object o1,
Object o2)
- Compares its two arguments for order. Returns a negative integer,
zero, or a positive integer as the first argument is less than, equal
to, or greater than the second.
The implementor must ensure that sgn(compare(x, y)) == -sgn(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)
The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.
Finally, the implementer must ensure that compare(x, y)==0 implies that sgn(compare(x, z))==sgn(compare(y, z)) for all z.
It is generally the case, but not strictly required that (compare(x, y)==0) == (x.equals(y)). Generally speaking, any comparator that violates this condition should clearly indicate this fact. The recommended language is "Note: this comparator imposes orderings that are inconsistent with equals."
- Parameters:
o1- the first object to be compared.o2- the second object to be compared.- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- Throws:
ClassCastException- if the arguments' types prevent them from being compared by this Comparator.
On 11/29/05, Cosmin Bucur <[EMAIL PROTECTED]> wrote:
The value returned does not come from the comparator logic , but from
a method inside the File object . I won't be using File so I need to
know what int value i need to return from compare(Object o , Object o2
) under which cases
On 11/29/05, Cosmin Bucur <[EMAIL PROTECTED]> wrote:
> I wanted to know what values the Tacos tree is expecting for what cases
>
> Maybe it's just me having holes in my basic java knowledge then , and
> in this case working with the Comparator interface is a prerequisite
> of beeing able to manipulate tacos:Tree ?
>
> On 11/29/05, Jesse Kuhnert <[EMAIL PROTECTED] > wrote:
> > The Comparator interface is a java construct. Lots of the java internals
> > already implement Comparable, like String/numbers/etc.. (I think).
> >
> > Not sure what you want explained here? There are probably lots of tutorials
> > on this on the net.
> >
> >
> > On 11/29/05, Cosmin Bucur <[EMAIL PROTECTED]> wrote:
> > >
> > > I just want to build my own type of PartialTree , that instead of
> > > files shows other objects .
> > >
> > > In fact the scenario is a bit different as the objects shown in the
> > > tree are not a single type of object ( allthohugh I might need to
> > > write a single type of object enccapsulating diferentiation logic ...
> > > i don't know , still trying to get how the tree's working )
> > >
> > > Right now i'm stuck at the FileComparator . My first baby step was to
> > > recreate Partial Tree in my app , and get it working . Got that . Now
> > > next step is to replace the File objects in the tree with something
> > > else that at least gets shown on the new level , and the link logic
> > > works ...
> > >
> > > My question here is . The compare method returns and int . I looked at
> > > the javaDocs and it looks like the method used on the file could
> > > return a 0 , negativev or positive int . . .
> > >
> > > What and how would I return stuff here ? ? ??
> > >
> > > I am very confused , a simple tree with no links it's easy to get ,
> > > but when you need something that actually has functionality ...
> > >
> > > Thanks .
> > > cosmin
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> > files
> > > for problems? Stop! Download the new AJAX search engine that makes
> > > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> > > http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
> > > _______________________________________________
> > > Tacos-devel mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/tacos-devel
> > >
> >
> >
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
_______________________________________________
Tacos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tacos-devel
