public static BitStore freeRangeViewOf(BitStore store, int from, int to, boolean extension) {
		if (from == to) return Bits.noBits();
		int size = store.size();
		if (size == 0) return Bits.noBits();
		if (from > to) {
			store = store.reversed();
			int t = from;
			from = to;
			to = t;
		}
		if ((long) to - (long) from > Integer.MAX_VALUE) throw new IllegalArgumentException("maximum size exceeded");
		if (to <= 0 || from >= size) return bits(extension, to - from);
		if (from == 0 && to == size) return store.immutableView();
		if (from >= 0 && to <= size) return store.immutableView().range(from, to);
		if (from >= 0) return new ExtendedBitStore(store.rangeFrom(from), extension, 0, to - size);
		if (to <= size) return new ExtendedBitStore(store.rangeTo(to), extension, 0 - from, 0);
		return new ExtendedBitStore(store, extension, 0 - from, to - size);
	}
public static BitStore freeRangeViewOf ( BitStore store , int from , int to , boolean extension ) { if ( from == to ) return Bits . noBits ( ) ; int size = store . size ( ) ; if ( size == 0 ) return Bits . noBits ( ) ; if ( from > to ) { store = store . reversed ( ) ; int t = from ; from = to ; to = t ; } if ( ( long ) to - ( long ) from > Integer . MAX_VALUE ) throw new IllegalArgumentException ( "maximum size exceeded" ) ; if ( to <= 0 || from >= size ) return bits ( extension , to - from ) ; if ( from == 0 && to == size ) return store . immutableView ( ) ; if ( from >= 0 && to <= size ) return store . immutableView ( ) . range ( from , to ) ; if ( from >= 0 ) return new ExtendedBitStore ( store . rangeFrom ( from ) , extension , 0 , to - size ) ; if ( to <= size ) return new ExtendedBitStore ( store . rangeTo ( to ) , extension , 0 - from , 0 ) ; return new ExtendedBitStore ( store , extension , 0 - from , to - size ) ; }
<p>
An immutable reindexed view of the supplied {@link BitStore}. The
returned store is a view over this store, changes in either are reflected
in the other. In contrast to the {@link BitStore#range(int, int)} method
this method places no restriction of on the <code>to</code> and
<code>from</code> parameters.

<p>
If <code>from</code> is less than zero and/or <code>to</code> exceeds the
store size, the view returned is padded with the specified extension
value. Additionally, if <code>from</code> exceeds <code>to</code>, the
view returned is reversed.

<p>
The returned store as a size of <code>to - from</code> and has its own
indexing, starting at zero (which maps to index <code>from</code> the
supplied store).

@param store
the bits backing the view
@param from
the start of the range (inclusive)
@param to
the end of the range (exclusive)
@param extension
whether the returned view should be padded with ones where the
range exceeds the bounds of the store, otherwise padding is
with zeros
@return a reindexed range of the supplied {@link BitStore}
@see BitStore#range(int,int)
@see BitStore#reversed()