Sorting a Set with a custom Comparator

Hi,
I wondered how to sort a Set with a custom Comparator. I know how to do this with a List: Collections.sort(list,new CustomComparator()).
But how can I do this with a Set?
Thanks
Jonny

If you want to just sort the Set on demand, you'd have to dump its contents into a List, sort the List, then dump its contents back into a LinkedHashSet.
If you want the set to always be in sorted order, use a SortedSet, such as TreeSet.

Similar Messages

  • LINQ grouping with custom comparer

    I'm trying to implement a linq grouping with a custom comparer. I have a datatable, I fill it with data, then I add the datarows to a
    List(Of DataRow), then I select all the rows to a IEnumerable(Of Object()). After that, I would like to group the result with a custom comprarer.
    This is the code:
    Dim result As IEnumerable(Of Object())
    Dim dt As New DataTable
    Dim indexes As New List(Of Integer)
    Dim groupedindexes As New List(Of Integer)
    Dim datarows As New List(Of DataRow)
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    dt.Columns.Add("f1", Type.GetType("System.Char"))
    dt.Columns.Add("f2", Type.GetType("System.Char"))
    dt.Columns.Add("f3", Type.GetType("System.Char"))
    For i = 0 To 100
    dt.Rows.Add("a", "b", "c")
    Next
    indexes.Add(0)
    indexes.Add(1)
    indexes.Add(2)
    groupedindexes.Add(0)
    groupedindexes.Add(1)
    groupedindexes.Add(2)
    For i = 0 To dt.Rows.Count - 1
    datarows.Add(dt.Rows(i))
    Next
    result = datarows.Select(Function(row) indexes.Select(Function(index) row(index)).ToArray)
    Dim test = result.GroupBy(Function(row) groupedindexes.Select(Function(grpindex) row(grpindex)).ToArray, New compare)
    End Sub
    And this is the compare class:
    Partial Class compare
    Implements System.Collections.Generic.IEqualityComparer(Of Object())
    Public Function Equals1(ByVal x() As Object, ByVal y() As Object) As Boolean Implements System.Collections.Generic.IEqualityComparer(Of Object()).Equals
    Dim equal As Boolean = True
    For i = 0 To x.Count - 1
    If x(i) IsNot y(i) Then
    equal = False
    Exit For
    End If
    Next
    Return equal
    End Function
    Public Function GetHashCode1(ByVal obj() As Object) As Integer Implements System.Collections.Generic.IEqualityComparer(Of Object()).GetHashCode
    Dim hashcode As Integer
    For i = 0 To obj.Count - 1
    hashcode = hashcode + obj(i).GetHashCode
    Next
    Return hashcode
    End Function
    End Class
    With the above code, I get all the 101 rows, but I would like to get only one row (a, b, c), since all the rows are the same. Therefore I wrote the custom comparer class. I'm new to this and I'm not sure, that I use it correct.
    Can you advise me, how should I modify the code to get only one row?
    Thanks.

    Try code below.  I use a dictionary to group rows and then filter results to get unique rows.
    Module Module1
    Sub Main()
    Dim dt As New DataTable
    Dim dict As Dictionary(Of Integer, List(Of DataRow)) = dt.AsEnumerable() _
    .GroupBy(Function(x) x.Field(Of Integer)("Col A"), Function(y) y) _
    .ToDictionary(Function(x) x.Key, Function(y) compare(y.ToList()))
    End Sub
    Function compare(rows As List(Of DataRow)) As List(Of DataRow)
    Dim results As New List(Of DataRow)
    results.Add(rows.FirstOrDefault)
    If (rows.Count > 1) Then
    For i = 1 To (rows.Count - 1)
    Dim unique As Boolean = True
    Dim rowArray() As Object = rows(i).ItemArray
    For j = 0 To (results.Count - 1)
    Dim oldArray() As Object = results(j).ItemArray
    For cols = 0 To (rowArray.Length - 1)
    If rowArray(i) <> oldArray(j) Then
    unique = False
    Exit For
    End If
    Next cols
    If unique = False Then
    Exit For
    End If
    Next j
    If unique = True Then
    results.Add(rows(i))
    End If
    Next i
    End If
    Return results
    End Function
    End Module
    jdweng

  • Sorting a hashmap with duplicate values

    How would i sort the hashmap values in ascending order with duplicated values. thanks.

    One cannot sort a Collection unless it is a List or implements one of the sorted interfaces. Retrieving the values, one would have to put all of them into a List prior to sorting.
    If you need an ordered map that is ordered by its values, you need a custom class or a TreeMap with a custom Comparator. Read the according tutorials on Collection and ordering.
    http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html

  • Slow performance with custom comparator (AdvancedDataGrid sorting)

    I'm using Flex 3.4.
    I have an advancedDataGrid. Have 2 columns with numbers as data.
    For one column, I do not set any custom comparator function.
    For the other column, I set a custom comparator function which is exactly the same as the default one used by Flex. (The private function SortField.numericCompare).
    For both columns, I set the same data - 3000 Rows with values either 0 or 1.
    When i sort on column1 (the one with custom comparator), the sorting is much slower than on column2 (default Flex comparator).
    I went through the AdvancedDataGrid/SortField source codes but could not see why this could be happening as the comparator functions are the same in both cases.
    Also, I checked out this bug -
    http://bugs.adobe.com/jira/browse/SDK-13118
    But shouldn't this be applicable to both custom and default sorting?
    Can anyone help me out?

    This is the function that i have : (same as the SortField numericCompare function which is the default function which is used if no customCompare is specified.)
            public function numCompare(a:Object, b:Object):int {
                var fa:Number;
                try {
                    fa = _name == null ? Number(a) : Number(a[_name]);
                } catch (error:Error) {
                var fb:Number;
                try {
                    fb = _name == null ? Number(b) : Number(b[_name]);
                } catch (error:Error) {
                return ObjectUtil.numericCompare(fa, fb);
    As per bug, the performance should be slow for lots of items that have same value. But, it should be the same for both the custom compare and the default compare as the custom compare function I'm using is the same as what is used for Flex.

  • Sort order by custom comparable logic

    Hi All,
    Is it possible to sort the records from NamedCache.entrySet() by implementing Comparable<T> in my pojo?
    Thanks,

    user1096084 wrote:
    Thanks for your quick response.
    My requirement is to fetch objects without filter but with custom sort order and
    I couldn't find any method in QueryMap for this purpose.
    What will be result if implement Comparable interface in object?Hi,
    1. You can always use AlwaysFilter.INSTANCE for filtering.
    2. You can use a parallel aggregator to parallelly presort objects and also limit the number of objects you fetch.
    Implementing Comparable with the objects allows you to call entrySet(Filter, Comparator) with null for comparator. The method entrySet() without parameters or the entrySet(Filter) do not sort regardless of whether your objects implement comparable or not.
    Best regards,
    Robert

  • Custom comparator with LimitFilter

    When I use a custom comparator with a LimitFilter, the results within the limit are returned first and then the comparator is applied, instead of applying the comparator on the complete result set, and then limit them. Is there a way to achieve the scenario I am expecting?
    Thank is advance

    I am also on coherence version 3.5.2
    1. custom-pof-config.xml:
    <?xml version="1.0"?>
    <!DOCTYPE pof-config SYSTEM "pof-config.dtd">
    <pof-config>
         <user-type-list>
              <include>coherence-pof-config.xml</include>
              <user-type>
                   <type-id>2001</type-id>
                   <class-name>com.biperf.cache.example.CacheItem</class-name>
              </user-type>
              <user-type>
                   <type-id>2002</type-id>
                   <class-name>com.biperf.cache.example.CacheSubItem1</class-name>
              </user-type>
              <user-type>
                   <type-id>2003</type-id>
                   <class-name>com.biperf.cache.example.CacheSubItem2</class-name>
              </user-type>
              <user-type>
                   <type-id>2004</type-id>
                   <class-name>com.biperf.cache.example.CustomFilter1</class-name>
              </user-type>
              <user-type>
                   <type-id>2005</type-id>
                   <class-name>com.biperf.cache.example.CustomComparator1</class-name>
              </user-type>
              <user-type>
                   <type-id>2006</type-id>
                   <class-name>com.biperf.cache.example.CustomProcessor1</class-name>
              </user-type>
         </user-type-list>
         <allow-interfaces>true</allow-interfaces>
         <allow-subclasses>true</allow-subclasses>
    </pof-config>2. Domain objects:
    public class CacheItem extends AbstractEvolvable implements EvolvablePortableObject, java.io.Serializable, com.tangosol.io.pof.PortableObject
      private static final int VERSION = 1;
      private static final long serialVersionUID = -1L;
      private long cacheItemId;
      private Set<CacheSubItem1> item1 = new HashSet<CacheSubItem1>();
      private Set<String> item2 = new HashSet<String>();
      private Set<Long> item3 = new HashSet<Long>();
      public long getCacheItemId()
        return cacheItemId;
      public void setCacheItemId( long cacheItemId )
        this.cacheItemId = cacheItemId;
      public Set<CacheSubItem1> getItem1()
        return item1;
      public void setItem1( Set<CacheSubItem1> item1 )
        this.item1 = item1;
      public Set<String> getItem2()
        return item2;
      public void setItem2( Set<String> item2 )
        this.item2 = item2;
      public Set<Long> getItem3()
        return item3;
      public void setItem3( Set<Long> item3 )
        this.item3 = item3;
      @SuppressWarnings( "unchecked" )
      @Override
      public void readExternal( PofReader reader ) throws IOException
        cacheItemId = reader.readLong( 0 );
        item1 = (Set<CacheSubItem1>)reader.readCollection( 1, item1 );
        item2 = (Set<String>)reader.readCollection( 2, item2 );
        item3 = (Set<Long>)reader.readCollection( 3, item3 );
      @Override
      public void writeExternal( PofWriter writer ) throws IOException
        writer.writeLong( 0, cacheItemId );
        writer.writeCollection( 1, item1 );
        writer.writeCollection( 2, item2 );
        writer.writeCollection( 3, item3 );
      @Override
      public int getImplVersion()
        return VERSION ;
    public class CacheSubItem1 extends AbstractEvolvable implements EvolvablePortableObject, java.io.Serializable, com.tangosol.io.pof.PortableObject
      private static final int VERSION = 1;
      private static final long serialVersionUID = -1L;
      private Map<Integer, CacheSubItem2> item1 = new HashMap<Integer, CacheSubItem2>();
      public Map<Integer, CacheSubItem2> getItem1()
        return item1;
      public void setItem1( Map<Integer, CacheSubItem2> item1 )
        this.item1 = item1;
      @SuppressWarnings( "unchecked" )
      @Override
      public void readExternal( PofReader reader ) throws IOException
        item1 = (Map<Integer, CacheSubItem2>)reader.readMap( 0, item1 );
      @Override
      public void writeExternal( PofWriter writer ) throws IOException
        writer.writeMap( 0, item1 );
      @Override
      public int getImplVersion()
        return VERSION ;
    public class CacheSubItem2 extends AbstractEvolvable implements EvolvablePortableObject, java.io.Serializable, com.tangosol.io.pof.PortableObject
      private static final int VERSION = 1;
      private static final long serialVersionUID = -1L;
      private int value;
      private boolean flag;
      public int getValue()
        return value;
      public void setValue( int value )
        this.value = value;
      public boolean isFlag()
        return flag;
      public void setFlag( boolean flag )
        this.flag = flag;
      @Override
      public void readExternal( PofReader reader ) throws IOException
        value = reader.readInt( 0 );
        flag = reader.readBoolean( 1 );
      @Override
      public void writeExternal( PofWriter writer ) throws IOException
        writer.writeInt( 0, value );
        writer.writeBoolean( 1, flag );
      @Override
      public int getImplVersion()
        return VERSION ;
    public class CustomComparator1 implements java.io.Serializable, Comparator<CacheItem>, com.tangosol.io.pof.PortableObject
      private static final long serialVersionUID = -1L;
      private int sortOrder = 1 ;
      private Integer key ;
      public CustomComparator1(){}
      public CustomComparator1( Integer key )
        this.key = key ;
      @Override
      public int compare( CacheItem item1, CacheItem item2 )
        return sortOrder * ( getValue( item1 ).compareTo( getValue( item2 ) )  ) ;
      private Integer getValue( CacheItem item )
        int value = item.getItem1().iterator().next().getItem1().get( key ).getValue() ;
        return new Integer( value ) ;
      @Override
      public void readExternal( PofReader reader ) throws IOException
        sortOrder = reader.readInt( 0 ) ;
        key = reader.readInt( 1 ) ;
      @Override
      public void writeExternal( PofWriter writer ) throws IOException
        writer.writeInt( 0, sortOrder ) ;
        writer.writeInt( 1, key ) ;
      public void setAscendingOrder()
        sortOrder = 1 ;
      public void setDescendingOrder()
        sortOrder = -1 ;
    public class CustomFilter1 implements Filter, java.io.Serializable, com.tangosol.io.pof.PortableObject
      private static final long serialVersionUID = -1L;
      private Integer key = null ;
      public CustomFilter1(){}
      public CustomFilter1( Integer key )
        super() ;
        this.key = key ;
      @Override
      public boolean evaluate( Object item )
        for( CacheSubItem1 subItem1: ((CacheItem)item).getItem1() )
          CacheSubItem2 subItem2 = subItem1.getItem1().get( key );
          if(null!=subItem2){
            return true ;
        return false ;
      @Override
      public void readExternal( PofReader reader ) throws IOException
        key = reader.readInt( 0 ) ;
      @Override
      public void writeExternal( PofWriter writer ) throws IOException
        writer.writeInt( 0, key ) ;
    public class CustomProcessor1 extends AbstractProcessor implements PortableObject
      private static final long serialVersionUID = -1L;
      private Integer key ;
      private Set<String> item2s = new HashSet<String>();
      public CustomProcessor1(){}
      public CustomProcessor1( Integer key, Set<String> item2s )
        this.key = key ;
        this.item2s = item2s ;
      @Override
      public Object process( com.tangosol.util.InvocableMap.Entry entry )
        if ( !entry.isPresent() )
          return null ;
        CacheItem item = (CacheItem)entry.getValue() ;
        return extract( item ) ;
      public CacheItem extract( CacheItem item )
        CacheItem extract = new CacheItem() ;
        extract.setCacheItemId( item.getCacheItemId() );
        Set<CacheSubItem1> item1s = item.getItem1() ;
        for( CacheSubItem1 item1: item1s )
          extract.getItem1().add( getExtractedItem1( item1 ) ) ;
        for( String item2: item2s )
          if( item.getItem2().contains( item2 ) )
            extract.getItem2().add( item2 );
        return extract ;
      private CacheSubItem1 getExtractedItem1( CacheSubItem1 hydrated )
        CacheSubItem1 extracted = new CacheSubItem1() ;
        extracted.getItem1().put( key, hydrated.getItem1().get( key ) ) ;
        return extracted ;
      public Integer getKey()
        return key;
      public void setKey( Integer key )
        this.key = key;
      public Set< String > getItem2s()
        return item2s;
      public void setItem2s( Set< String > item2s )
        this.item2s = item2s;
      @SuppressWarnings( "unchecked" )
      @Override
      public void readExternal( PofReader reader ) throws IOException
        key = reader.readInt( 0 ) ;
        item2s = (Set<String>)reader.readCollection( 1, item2s );
      @Override
      public void writeExternal( PofWriter writer ) throws IOException
        writer.writeInt( 0, key ) ;
        writer.writeCollection( 1, item2s );
    }3. Cache data loader:
    public class CacheDataLoader
      public static final String BASE_ITEM2_KEY = "12345678901234567890";
      public static final char[] VALID_CHARS =
      {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J',
      'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'T', 'U',
      'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4',
      '5', '6', '7', '8', '9', '0'} ;
      public static final int NUMBER_OF_ITEM2 = 1000 ;
      public static final int NUMBER_OF_ITEM3 = 1000 ;
      public static final int NUMBER_OF_ITEM = 20000;
      public static final int BATCH_LOAD_SIZE = 10000 ;
      public static final int NUMBER_OF_KEYS_PER_SUBITEM1 = 50;
      public static final int MULITPLE_ITEM1_FREQUENCY = 1000 ;
      public static final int NUMBER_OF_MULTIPLE_ITEM1 = 1;
      public static final int MULITPLE_ITEM2_FREQUENCY = 2;
      public static final int NUMBER_OF_MULTIPLE_ITEM2 = 3;
      public static final int MULITPLE_ITEM3_FREQUENCY = 2;
      public static final int NUMBER_OF_MULTIPLE_ITEM3 = 5;
      public static final long BASE_CACHE_ITEM_KEY = 10000000 ;
      public static final long BASE_ITEM3_KEY = 10000000;
      private long item3Count = 0;
      private long item2Count = 0;
      private long cacheItemCount = 0;
      private NamedCache cache = CacheFactory.getCache( "cache-data" ) ;
      public static void main( String[] args )
        CacheDataLoader loader = new CacheDataLoader() ;
        loader.load() ;
        loader.createIndices() ;
      private void createIndices()
        cache.addIndex( new KeyExtractor( IdentityExtractor.INSTANCE ), false, null );
        cache.addIndex( new ReflectionExtractor( "getItem2" ), false, null );
        cache.addIndex( new ReflectionExtractor( "getItem3" ), false, null );
      private void load()
        long start = System.currentTimeMillis();
        cache.clear();
        int iterations = NUMBER_OF_ITEM/BATCH_LOAD_SIZE ;
        for ( int i=0;i<iterations; i++ )
          cache.putAll( getCacheItems( BATCH_LOAD_SIZE ) );
        System.out.println( "CACHE LOAD: Instances: " + cache.size() + " keysize: " + NUMBER_OF_KEYS_PER_SUBITEM1 + " Time: " + ( System.currentTimeMillis() - start ) );
      private Map<Long, CacheItem> getCacheItems( int loadSize )
        Map<Long, CacheItem> cacheItems = new HashMap<Long, CacheItem>() ;
        for( int i=0; i<loadSize; i++)
          CacheItem cacheItem = getCacheItem();
          cacheItems.put( cacheItem.getCacheItemId(), cacheItem ) ;
        return cacheItems ;
      private CacheItem getCacheItem()
        CacheItem cacheItem = new CacheItem();
        cacheItem.setCacheItemId( getNextCacheItemId() );
        cacheItem.setItem1( getItem1() ) ;
        cacheItem.setItem2( getItem2() );
        cacheItem.setItem3( getItem3() );
        return cacheItem;
      private Set<Long> getItem3()
        Set<Long> item3s = new HashSet<Long>() ;
        //First item3
        item3s.add( getNextItem3Id() ) ;
        //Additional item3s
        if( isAdditionalItem3Required() )
          for(int i=0; i<NUMBER_OF_MULTIPLE_ITEM3; ++i){
            item3s.add( getNextItem3Id() ) ;
        return item3s;
      private Set<String> getItem2()
        Set<String> item2s = new HashSet<String>() ;
        //First item2
        item2s.add( getNextItem2Id() ) ;
        //Additional item2s
        if( isAdditionalItem2Required() )
          for(int i=0; i<NUMBER_OF_MULTIPLE_ITEM2; ++i){
            item2s.add( getNextItem2Id() ) ;
        return item2s;
      private Set<CacheSubItem1> getItem1()
        Set<CacheSubItem1> item1s = new HashSet<CacheSubItem1>() ;
        //First item1
        item1s.add( getSubItem1() ) ;
        //Additional item1s
        if( isAdditionalItem1Required() )
          for(int i=0; i<NUMBER_OF_MULTIPLE_ITEM1; ++i){
            item1s.add( getSubItem1() ) ;
        return item1s;
      private CacheSubItem1 getSubItem1()
        CacheSubItem1 item = new CacheSubItem1() ;
        item.setItem1( getSubItemMap( NUMBER_OF_KEYS_PER_SUBITEM1 ) ) ;
        return item;
      private Map<Integer, CacheSubItem2> getSubItemMap( int numberPriceKeys )
        Map<Integer, CacheSubItem2> items = new HashMap<Integer, CacheSubItem2>();
        for ( int x = 0; x < numberPriceKeys; x++ )
          Integer key = x;
          items.put( key, getSubItem2() );
        return items;
      private CacheSubItem2 getSubItem2()
        CacheSubItem2 item = new CacheSubItem2() ;
        item.setFlag( RandomUtils.nextBoolean() ) ;
        item.setValue( getRandomValue() ) ;
        return item;
      private boolean isAdditionalItem1Required()
        return cacheItemCount%MULITPLE_ITEM1_FREQUENCY == 0;
      private boolean isAdditionalItem2Required()
        return cacheItemCount%MULITPLE_ITEM2_FREQUENCY == 0;
      private boolean isAdditionalItem3Required()
        return cacheItemCount%MULITPLE_ITEM3_FREQUENCY == 0;
      private long getNextCacheItemId()
        return BASE_CACHE_ITEM_KEY + (++cacheItemCount);
      private long getNextItem3Id()
        return BASE_ITEM3_KEY + (++item3Count%NUMBER_OF_ITEM3);
      private String getNextItem2Id()
        return BASE_ITEM2_KEY + (++item2Count%NUMBER_OF_ITEM2);
      private int getRandomValue()
        return RandomUtils.nextInt( 10000 ) ;
    }4. Test Case:
    public class TestExampleCache extends TestCase
      public void testLimitFilter1()
        final Integer key = getKey();
        Set<String> item2 = getItem2();
        Set<Long> item3 = getItem3();
        CustomComparator1 comparator = new CustomComparator1(key);
        comparator.setAscendingOrder();
        Filter[] filterArray = { new ContainsAnyFilter( "getItem2", item2 ),
                                 new ContainsAnyFilter( "getItem3", item3 ),
                                 new CustomFilter1( key ) };
        Filter allFilter = new AllFilter( filterArray ) ;
        CustomProcessor1 processor = new CustomProcessor1(key,item2);
        Set<Map.Entry<Long, CacheItem>> result1 = CacheFactory.getCache( "cache-data" ).entrySet( allFilter,comparator );
        for(Map.Entry<Long, CacheItem> entry : result1 ){
          CacheItem item = processor.extract( entry.getValue() );
          System.out.println(item.getCacheItemId()+"-"+item.getItem1().iterator().next().getItem1().values().iterator().next().getValue());
        System.out.println();
      public void testLimitFilter2()
        final Integer key = getKey();
        final int numberOfProducts = 10;
        Set<String> item2 = getItem2();
        Set<Long> item3 = getItem3();
        CustomComparator1 comparator = new CustomComparator1(key);
        comparator.setAscendingOrder();
        Filter[] filterArray = { new ContainsAnyFilter( "getItem2", item2 ),
                                 new ContainsAnyFilter( "getItem3", item3 ),
                                 new CustomFilter1( key ) };
        Filter allFilter = new AllFilter( filterArray ) ;
        LimitFilter limitFilter = new LimitFilter(allFilter, numberOfProducts);
        CustomProcessor1 processor = new CustomProcessor1(key,item2);
        Set<Map.Entry<Long, CacheItem>> result1 = CacheFactory.getCache( "cache-data" ).entrySet( limitFilter,comparator );
        for(Map.Entry<Long, CacheItem> entry : result1 ){
          CacheItem item = processor.extract( entry.getValue() );
          System.out.println(item.getCacheItemId()+"-"+item.getItem1().iterator().next().getItem1().values().iterator().next().getValue());
        System.out.println();
        limitFilter.nextPage();
        Set<Map.Entry<Long, CacheItem>> result2 = CacheFactory.getCache( "cache-data" ).entrySet( limitFilter,comparator );
        for(Map.Entry<Long, CacheItem> entry : result2 ){
          CacheItem item = processor.extract( entry.getValue() );
          System.out.println(item.getCacheItemId()+"-"+item.getItem1().iterator().next().getItem1().values().iterator().next().getValue());
      private Integer getKey()
        return new Integer(10);
      private Set<String> getItem2()
        Set<String> items = new HashSet<String>();
        items.add( "12345678901234567890" + 1 );
        items.add( "12345678901234567890" + 2 );
        items.add( "12345678901234567890" + 3 );
        items.add( "12345678901234567890" + 4 );
        items.add( "12345678901234567890" + 5 );
        items.add( "12345678901234567890" + 6 );
        items.add( "12345678901234567890" + 7 );
        items.add( "12345678901234567890" + 8 );
        items.add( "12345678901234567890" + 9 );
        items.add( "12345678901234567890" + 10 );
        items.add( "12345678901234567890" + 11 );
        items.add( "12345678901234567890" + 12 );
        return items;
      private Set<Long> getItem3()
        Set<Long> items = new HashSet<Long>();
        items.add( new Long(10000001) );
        items.add( new Long(10000002) );
        items.add( new Long(10000003) );
        items.add( new Long(10000004) );
        items.add( new Long(10000005) );
        items.add( new Long(10000006) );
        items.add( new Long(10000007) );
        items.add( new Long(10000008) );
        items.add( new Long(10000009) );
        items.add( new Long(10000010) );
        return items;
    }5. Results:
    a. testLimitFilter1()
    10010001-109
    10002002-121
    10002004-487
    10006003-726
    10008004-762
    10000004-845
    10010003-922
    10014003-1157
    10012002-1426
    10008002-1585
    10002003-1709
    10004004-2004
    10004001-2179
    10018002-2452
    10016004-3073
    10012004-3145
    10008001-3249
    10018001-3270
    10008003-3319
    10016002-3778
    10012001-4256
    10012003-4391
    10002001-4921
    10006002-5072
    10000002-5162
    10016003-5777
    10014004-6068
    10000001-6260
    10000003-6373
    10004002-6615
    10014001-7679
    10006001-7729
    10006004-7794
    10010002-8188
    10010004-8215
    10018004-8258
    10016001-8383
    10018003-8760
    10004003-9652
    10014002-9876
    b. testLimitFilter2()
    Page-1
    10002004-487
    10000004-845
    10012002-1426
    10008002-1585
    10004004-2004
    10018001-3270
    10016003-5777
    10006004-7794
    10016001-8383
    10018003-8760
    Page-2
    10018002-2452
    10008001-3249
    10008003-3319
    10016002-3778
    10012001-4256
    10012003-4391
    10014004-6068
    10000003-6373
    10010002-8188
    10010004-8215
    c. Expected results:
    Page-1
    10010001-109
    10002002-121
    10002004-487
    10006003-726
    10008004-762
    10000004-845
    10010003-922
    10014003-1157
    10012002-1426
    10008002-1585
    Page-2
    10002003-1709
    10004004-2004
    10004001-2179
    10018002-2452
    10016004-3073
    10012004-3145
    10008001-3249
    10018001-3270
    10008003-3319
    10016002-3778
    Edited by: user8065775 on Oct 21, 2009 3:02 PM
    PS : Looks like the following thread addresses the problem that I have mentioned, which has links to download the source code but they do not work. Is there a way that I can access the java source pointed to in the post pointed to by the following link?
    Re: The question about the locking of the cache
    SortByMethodNameAggregator.java
    SortByMethodNameCaller.java
    Can you please email me the code to [email protected]

  • I want to set up a custom footer for my office documents.  I have the home/student version of Office 2010 for Mac. Will I be better off purchasing Office for business or just stick with apple products.

    Hi,
    Can someone help me to set up a custom footer on my iMac.  Currently using home/student 2010 and it does not offer a custom option.  Will I need to purchase Microsoft business or would I be wasting my money.  I went to the apple store for guidance and they informed me they could not help me with the microsoft products.  To my surprise although apple has a version of microsoft, it is not a full version.  I did not purchase the apple word, excel, powerpoint and such to avoid problems sending letters and such to pc users.  Does anyone have advice or experience enough to let me know what issues may arise out of either choice. 

    Microsoft Office 2010 is out of date. You need to buy Office 2011.
    You can get more advice here:
    http://www.msofficeforums.com/

  • Receiving Error : Please set the Receivables system options for this operating unit and ensure that the MO: Operating Unit profile option is correctly set with an operating unit that is set up in Receivables. while trying to create a new Customer.

    Hi All,
    We have set up a new Operating Unit in Oracle Apps. Now when I am trying to create a new Customer in that Operating Unit, I am receiving following error:
    ERROR MESSAGE:-Please set the Receivables system options for this operating unit and ensure that the MO: Operating Unit profile option is correctly set with an operating unit that is set up in Receivables.
    We do have MO: Operating Unit and MO: Default Operating Unit set properly at Responsibility level for the Responsibility through which I am accessing this form.
    Your help is appreciated!
    Thanks in advance,
    SKA

    You can refer this thread and check your MO operating unit is set or not https://community.oracle.com/message/3937028 thanks

  • Search result category with a custom layout set?

    Greetings,
    I've created a nice little search IVIEW with a custom search options set that will display the document category (taxonomy) in the search result (if the resulting document is categorized, of course.)  Works great.  However there is one little problem.  The categories in the search results are hyperlinked and when you select one, you get a new window with the taxonomy rendered in the default layout set (the ConsumerExplorer I think.)  Not good.  I need this displayed in a custom layout set.
    Any ideas how to make this hyperlink use a custom layout set without changing the default?
    Regards,
    Paul Federighi

    Hi Paul,
    As per my knowledge of the basic s of layout sets and iviews.
    You want to change the layout set of the iview(window) which opens when u click the hyperlink.
    You should do this:
    1)Make a new layout set by customizing the default one.
    2)If the iview opening is a standard iview then go to its properties and change the Layout set value to ur new layout.
    Please revert in case of issues.
    I hope it helps.
    Regards,
    Sumit

  • Frustrated and seeking help with a custom sort order...

    I created a family photo album and arranged all of the pictures in a specific order and sync'd them with my iPad, unfortunately the pictures do not stay in the custom sequence.
    I tried Batch renaming with a Custom Name and Index, but the renaming is applied to the pictures based on the date they were created and not by the way I have arranged them.
    Is there a solution to my problem?
    TIA

    I flagged fifty photos and from that selection I created an album. I went to the album and dragged the photos in to the order I wanted them to appear after selecting Manual. Each time I now choose the manual option it arranges the photos into the sequence I created.
    The problem I'm having is that when I synchronize my iPad with iTunes the photos revert back to their original sort order, which is the default date they were brought in to Aperture.
    As I said, I tried to give them new names and index numbers using a batch command AFTER I arranged them manually, which works, however the names are assigned to the photos sequentially starting with oldest photos and not to photos as I have arranged them.
    Honestly, it would be easier for me to create a slideshow using the timeline in FCP, but a video is not what I'm after.
    I hope I have answered your questions.
    TIA

  • Phone died when on with a Customer Service agent.  Now both phones are dead...What do I do now?  Trying to set up my iphone 4S and I have no phone to call them back.

    Phone died when on with a Customer Service agent.  Now both phones are dead...What do I do now?  Trying to set up my iphone 4S and I have no phone to call them back.
    I was told I can set up my phone service through iTunes, but I can't seem to figure out where to go at this point.  Any help would be greatly appreciated!
    Greg

    what do you mean, it died? plug it into the power! :-)

  • HT201320 I have a new ipad mini - I am able to receive emails but not send - same with text. I have tried to follow the support advice. I have deleted my aol account and added it again. I have compared every setting with my husband, who has an ipad? Pleas

    I have a new ipad mini - I am able to receive emails but not send - same with text. I have tried to follow the support advice. I have deleted my aol account and added it again. I have compared every setting with my husband, who has an ipad? Please help

    ps when syncing it jumps through steps 1 - 4 real fast, i seem to remeber iphone showing the number of tracks transferring and names, but i see nothing? then it sits on 5 saying "waiting for changes to be applied"

  • De-Noise setting with custom RAW fine-tuning ?

    If I look at the De-Noise setting when using the Apple default you will notice that it varies with the ISO of the image (Njikon D4). As the ISO increases so does the De-Noise setting. This is often a good thing. If I save my own RAW fine-tuning setting with out touching the De-Noise setting and make it the Default, the De-Noise setting is no longer 'active' and just sits at zero for all ISO settings.
    How do we create a custom preset that will automatically increase De-Noise when the images have a higher ISO?
    JO

    leonieDF wrote:
    How do they differ after the last update? Ithink my Canon EOS 5D Mark II images now need less boost than before.
    I have speculated elsewhere that software and camera manufacturers are pushing hotter and more "Disney-fied" defaults than they have in the past (and that these have always been "unreal").  My experience with a Sony a77 is that the newest RAW upgrade reverses (or calms) this trend.
    The Sony a77 default setting under Apple RAW Compatibility Update 3 was too saturated and too contrasted (locally and globally).  I pulled back Boost to 0.7 and Hue Boost to 0.6, and left the rest the unchanged.  Under RAW Compatibility Update 4.0, I don't have to make as big a change, and settled on Boost=0.93 and HueBoost=0.70.  I also tweaked the other settings -- the biggest change there was putting moire to zero.
    That said -- I am having significant repeatable color problems with my NEC wide-gamut PA271W monitor, so I am going to have to revisit these settings after I resolve that.  I made the new settings based on the Retina display and an NEC 2490WUXi2.  They produce images that look great.  I have not printed any yet, but getting matching prints has not been a problem in the past.
    Do you change any settings other than Boost and Hue Boost?

  • Setting a Transport Rule to reply with a Custom DSN for a Disabled User and disconnected mailbox

    Here is what I am trying to accomplish. A user leaves the company. We disable there exchange email and that in turn disabled the account in AD. We want a custom NDR to say "This employee is no longer and employee blah blah" We dont get rid of email
    boxes but we disable them. 
    Here is what I done. Created custom NDR and then created a transport rule to read if the message is sent to [email protected] reply back with this NDR code. It works fine if I disable the user from AD and not exchange. Once I "disconnect" the mailbox
    it no longer works. I get the default NDR that says this email cant be found. I don't want that one. I want my custom NDR. I don't want to modify the 5.1.1 message either. Is there away around this?

    Hi Nellyjo,
    In your case, when you disable the user from AD and Exchange, in fact the message is blocked before reaching transport rule, recipient filtering is blocking this email. If you still want to achieve your goal by transport rule, you need to create a mailbox
    or contact to make your transport rule work.
    What's more, you also can modify original DSN for external and internal senders to meet your requirement.
    For more information, here is a similar thread for your reference.
    Setting a Transport Rule to reply with a Custom DSN for a Disabled User
    http://social.technet.microsoft.com/Forums/en-US/b1a4dd86-1e0e-43a9-b340-a80352e5c323/setting-a-transport-rule-to-reply-with-a-custom-dsn-for-a-disabled-user?forum=exchange2010
    Hope it helps.
    If you need further assistance, please feel free to let me know.
    Best regards,
    Amy
    Amy Wang
    TechNet Community Support

  • Wifi erratic on 4S after upgrading and not working even after resetting to factory setting. Why should apple isolate itself from their own product problems  Matter of shame when they are not ready to communicate with the customer means they are dead.

    11:22 (7 minutes ago)
    to AppleSupport
    Dear Sir/Madam Since  the wifi is not coming ON how can I open this diagnostic on the iphone  4S am using and having problem with wifi behaving in erratic manner. 
    Am  a professional engineer for projects and am 68 yrs old. At one time was  looking after a production line manufacturing I C's in semiconductors  manufacturing company of the US.
    Have four apple products, one hp laptop and one DELL professional computer at home is used by only two members me and my wife.
    Wife  prefers working on ipad2 or ipad mini while traveling and has iphone 4.  Am using iphone4S with laptop and Dell computer, No apple product is  more than two years old.
    Am having the problem in using wifi on the 4S after it  was upgraded to the latest ios as per the recommendation by your  software of my iphone 4S 
    The wifi card hangs up at  it's own will and even a visit to your authorized service center in  Delhi has not able to help me although they have reverted the ios back  to the
    one supplied with the set. Am a user and not a computer expert but it looks like the wifi card is  not able to some times take the load while working which could indicate  the wifi card is getting heated up.   
    My daughter  who is Masters in 3D Animation is an ardent fan of apple products  working at present in Canada was also gifted by me a 4S about 4 months  back. My daughter-in-law is using iphone4 and an ipad for her professional  works along with a Dell PC in the US. While my son is a fan of samsung  products and does not like an apple product. 
    So in a family we have 7 apple products except MAC laptop/PC. 
    But the fact is, this problem with 4S has  really shaken me up and now it seems your products are deteriorating in  quality while demanding the best pricing structures. 
    Since  this is purely the device and the software of apple problem you may  please replace this set with new one as neither have any time to push  you/ request you after your service centre
    in Delhi told me yesterday this cannot be repaired.   
    The  serial No of my set is DN*****TC0 and was bought from an authorized  dealer and so were the other products from the same dealer in Delhi.  This set is still in showroom condition and
    was never used without a protective cover. 
    Thanks 
    Ashok Dhingra
    D E E Hons B E Tech MBA
    Vasant Kunj Delhi
    <Personal Information Edited by Host>

    11:22 (7 minutes ago)
    to AppleSupport
    Dear Sir/Madam Since  the wifi is not coming ON how can I open this diagnostic on the iphone  4S am using and having problem with wifi behaving in erratic manner. 
    Am  a professional engineer for projects and am 68 yrs old. At one time was  looking after a production line manufacturing I C's in semiconductors  manufacturing company of the US.
    Have four apple products, one hp laptop and one DELL professional computer at home is used by only two members me and my wife.
    Wife  prefers working on ipad2 or ipad mini while traveling and has iphone 4.  Am using iphone4S with laptop and Dell computer, No apple product is  more than two years old.
    Am having the problem in using wifi on the 4S after it  was upgraded to the latest ios as per the recommendation by your  software of my iphone 4S 
    The wifi card hangs up at  it's own will and even a visit to your authorized service center in  Delhi has not able to help me although they have reverted the ios back  to the
    one supplied with the set. Am a user and not a computer expert but it looks like the wifi card is  not able to some times take the load while working which could indicate  the wifi card is getting heated up.   
    My daughter  who is Masters in 3D Animation is an ardent fan of apple products  working at present in Canada was also gifted by me a 4S about 4 months  back. My daughter-in-law is using iphone4 and an ipad for her professional  works along with a Dell PC in the US. While my son is a fan of samsung  products and does not like an apple product. 
    So in a family we have 7 apple products except MAC laptop/PC. 
    But the fact is, this problem with 4S has  really shaken me up and now it seems your products are deteriorating in  quality while demanding the best pricing structures. 
    Since  this is purely the device and the software of apple problem you may  please replace this set with new one as neither have any time to push  you/ request you after your service centre
    in Delhi told me yesterday this cannot be repaired.   
    The  serial No of my set is DN*****TC0 and was bought from an authorized  dealer and so were the other products from the same dealer in Delhi.  This set is still in showroom condition and
    was never used without a protective cover. 
    Thanks 
    Ashok Dhingra
    D E E Hons B E Tech MBA
    Vasant Kunj Delhi
    <Personal Information Edited by Host>

Maybe you are looking for

  • How do I add the pictures folder to the go menu in 10.8.4?

    I know I can put the folder in the dock, but I'd rather have access to it through the "go" menu. Is that possible?

  • Calling a super.ssuper.method but your super is a abstract class.

    Dear guys, Is that possible to invoke your super's super's method but your super is a abstract class? like: class GO {   public void draw() { } } abstract class GORunner extends GO {} class GOCounter extends GORunner { public void draw() { super.supe

  • Dump error during CK24  - SAPSQL_ARRAY_INSERT_DUPREC

    Hi SAP Gurus, i am facing problem during the material updation (T.Code CK24). before that i have done the material cost estimation then try to update material master by using t.code CK24. the following dump error occurs: Runtime Errors         SAPSQL

  • Exporting a movie in a lower resolution

    Hi there, I have made some demonstration movies of one of our business applications. This movie has been made for different countries in a resolution of 1280 x 1024 pixels. A Spanish colleague mentioned that this resolution was too high and that they

  • Which Sequence Preset Please Help

    I'm making a small video for my internship and using adobe Premiere. I've however run into a few problems. The camera was outputing video in AVCHD(.mts) files which where not working. I've nowstarted to convert the files into different formates. But