public static IntSet from ( Set < Integer > integerSet ) { if ( integerSet instanceof IntSet ) { return ( IntSet ) integerSet ; } int size = integerSet . size ( ) ; switch ( size ) { case 0 : return EmptyIntSet . getInstance ( ) ; case 1 : return new SingletonIntSet ( integerSet . iterator ( ) . next ( ) ) ; default : return new SmallIntSet ( integerSet ) ; } }
Returns an IntSet based on the provided Set . This method tries to return or create the most performant IntSet based on the Set provided . If the Set is already an IntSet it will just return that . The returned IntSet may or may not be immutable so no guarantees are provided from that respect .