@SuppressWarnings("unchecked") public AbstractConcurrentOffHeapMap(Factory<? extends Segment<K,V>> segmentFactory,int concurrency){
  if (concurrency <= 0) {
    throw new IllegalArgumentException("Concurrency must be positive [was: " + concurrency + "]");
  }
  if (concurrency > MAX_SEGMENTS) {
    concurrency=MAX_SEGMENTS;
  }
  int sshift=0;
  int ssize=1;
  while (ssize < concurrency) {
    ++sshift;
    ssize<<=1;
  }
  segmentShift=32 - sshift;
  segmentMask=ssize - 1;
  this.segments=new Segment[ssize];
  try {
    for (int i=0; i < this.segments.length; ++i) {
      this.segments[i]=segmentFactory.newInstance();
    }
  }
 catch (  RuntimeException e) {
    for (    Segment<?,?> s : this.segments) {
      if (s != null) {
        s.destroy();
      }
    }
    throw e;
  }
}

@ SuppressWarnings ( "unchecked" ) public AbstractConcurrentOffHeapMap ( Factory < ? extends Segment < K , V > > segmentFactory , int concurrency ) { if ( concurrency <= 0 ) { throw new IllegalArgumentException ( "Concurrency must be positive [was: " + concurrency + "]" ) ; } if ( concurrency > MAX_SEGMENTS ) { concurrency = MAX_SEGMENTS ; } int sshift = 0 ; int ssize = 1 ; while ( ssize < concurrency ) { ++ sshift ; ssize <<= 1 ; } segmentShift = 32 - sshift ; segmentMask = ssize - 1 ; this . segments = new Segment [ ssize ] ; try { for ( int i = 0 ; i < this . segments . length ; ++ i ) { this . segments [ i ] = segmentFactory . newInstance ( ) ; } } catch ( RuntimeException e ) { for ( Segment < ? , ? > s : this . segments ) { if ( s != null ) { s . destroy ( ) ; } } throw e ; } }
create a concurrent map with a defined number of segments .
