New StackOverflow Question: How does 'unique' work in the TotallyLazy library

6 views
Skip to first unread message

stacko...@mg.bodar.com

unread,
May 22, 2017, 8:17:31 AM5/22/17
to total...@googlegroups.com

How does 'unique' work in the TotallyLazy library

Asked by Chris Nash on 2014-09-08T18:04:54Z

Reply on StackOverflow

How can I use the 'unique' method in the TotallyLazy library for Java and Objective-C?

I have the following code, but I cannot complete it because I'm not sure how the Callable1 instance passed into 'unique' should be composed. Here's what I have so far:

        seq
        .sort(new Comparator<T>() {
            @Override
            public int compare(
                final T pt1,
                final T pt2
            ) {
                return pt1.compareTo(pt2);
            }
        })
        .unique(new Callable1<T,T>() {
            @Override
            public T call(final T pt) throws Exception {
                final int result = pt.compareTo(..?);
                return result != 0;
            }});

As you can see, I can sort successfully, but when it comes to "result = ..." in the 'unique' call, what should I put?

Reply on StackOverflow
Reply all
Reply to author
Forward
0 new messages