protected <S extends AddressDivisionBase> S[] createNewPrefixedDivisions(int bitsPerDigit, IPAddressNetwork<?, ?, ?, ?, ?> network, Integer networkPrefixLength, PrefixedGroupingCreator<S> groupingCreator, IntFunction<S[]> groupingArrayCreator) {
		if(bitsPerDigit >= Integer.SIZE) {
			//keep in mind once you hit 5 bits per digit, radix 32, you need 32 different digits, and there are only 26 alphabet characters and 10 digit chars, so 36
			//so once you get higher than that, you need a new character set.
			//AddressLargeDivision allows all the way up to base 85
			throw new AddressValueException(bitsPerDigit);
		}
		int bitCount = getBitCount();
		List<Integer> bitDivs = new ArrayList<Integer>(bitsPerDigit);
		//ipv6 octal:
		//seg bit counts: 63, 63, 2
		//ipv4 octal:
		//seg bit counts: 30, 2
		int largestBitCount = Long.SIZE - 1;
		largestBitCount -= largestBitCount % bitsPerDigit;
		do {
			if(bitCount <= largestBitCount) {
				int mod = bitCount % bitsPerDigit;
				int secondLast = bitCount - mod;
				if(secondLast > 0) {
					bitDivs.add(secondLast);
				}
				if(mod > 0) {
					bitDivs.add(mod);
				}
				break;
			} else {
				bitCount -= largestBitCount;
				bitDivs.add(largestBitCount);
			}
		} while(true);
		int bitDivSize = bitDivs.size();
		S divs[] = groupingArrayCreator.apply(bitDivSize);
		int currentSegmentIndex = 0;
		AddressDivision seg = getDivision(currentSegmentIndex);
		long segLowerVal = seg.getDivisionValue();
		long segUpperVal = seg.getUpperDivisionValue();
		int segBits = seg.getBitCount();
		int bitsSoFar = 0;
		int radix = AddressDivision.getRadixPower(BigInteger.valueOf(2), bitsPerDigit).intValue();
		//fill up our new divisions, one by one
		for(int i = bitDivSize - 1; i >= 0; i--) {
			int originalDivBitSize, divBitSize;
			originalDivBitSize = divBitSize = bitDivs.get(i);
			long divLowerValue, divUpperValue;
			divLowerValue = divUpperValue = 0;
			while(true) {
				if(segBits >= divBitSize) {
					int diff = segBits - divBitSize;
					divLowerValue |= segLowerVal >>> diff;
					int shift = ~(~0 << diff);
					segLowerVal &= shift;
					divUpperValue |= segUpperVal >>> diff;
					segUpperVal &= shift;
					segBits = diff;
					Integer segPrefixBits = networkPrefixLength == null ? null : getSegmentPrefixLength(originalDivBitSize, networkPrefixLength - bitsSoFar);
					S div = groupingCreator.createDivision(divLowerValue, divUpperValue, originalDivBitSize, radix, network, segPrefixBits);
					divs[bitDivSize - i - 1] = div;
					if(segBits == 0 && i > 0) {
						//get next seg
						seg = getDivision(++currentSegmentIndex);
						segLowerVal = seg.getDivisionValue();
						segUpperVal = seg.getUpperDivisionValue();
						segBits = seg.getBitCount();
					}
					break;
				} else {
					int diff = divBitSize - segBits;
					divLowerValue |= segLowerVal << diff;
					divUpperValue |= segUpperVal << diff;
					divBitSize = diff;
					
					//get next seg
					seg = getDivision(++currentSegmentIndex);
					segLowerVal = seg.getDivisionValue();
					segUpperVal = seg.getUpperDivisionValue();
					segBits = seg.getBitCount();
				}
			}
			bitsSoFar += originalDivBitSize;
		}
		return divs;
	}
protected < S extends AddressDivisionBase > S [ ] createNewPrefixedDivisions ( int bitsPerDigit , IPAddressNetwork < ? , ? , ? , ? , ? > network , Integer networkPrefixLength , PrefixedGroupingCreator < S > groupingCreator , IntFunction < S [ ] > groupingArrayCreator ) { if ( bitsPerDigit >= Integer . SIZE ) { throw new AddressValueException ( bitsPerDigit ) ; } int bitCount = getBitCount ( ) ; List < Integer > bitDivs = new ArrayList < Integer > ( bitsPerDigit ) ; int largestBitCount = Long . SIZE - 1 ; largestBitCount -= largestBitCount % bitsPerDigit ; do { if ( bitCount <= largestBitCount ) { int mod = bitCount % bitsPerDigit ; int secondLast = bitCount - mod ; if ( secondLast > 0 ) { bitDivs . add ( secondLast ) ; } if ( mod > 0 ) { bitDivs . add ( mod ) ; } break ; } else { bitCount -= largestBitCount ; bitDivs . add ( largestBitCount ) ; } } while ( true ) ; int bitDivSize = bitDivs . size ( ) ; S divs [ ] = groupingArrayCreator . apply ( bitDivSize ) ; int currentSegmentIndex = 0 ; AddressDivision seg = getDivision ( currentSegmentIndex ) ; long segLowerVal = seg . getDivisionValue ( ) ; long segUpperVal = seg . getUpperDivisionValue ( ) ; int segBits = seg . getBitCount ( ) ; int bitsSoFar = 0 ; int radix = AddressDivision . getRadixPower ( BigInteger . valueOf ( 2 ) , bitsPerDigit ) . intValue ( ) ; for ( int i = bitDivSize - 1 ; i >= 0 ; i -- ) { int originalDivBitSize , divBitSize ; originalDivBitSize = divBitSize = bitDivs . get ( i ) ; long divLowerValue , divUpperValue ; divLowerValue = divUpperValue = 0 ; while ( true ) { if ( segBits >= divBitSize ) { int diff = segBits - divBitSize ; divLowerValue |= segLowerVal > > > diff ; int shift = ~ ( ~ 0 << diff ) ; segLowerVal &= shift ; divUpperValue |= segUpperVal > > > diff ; segUpperVal &= shift ; segBits = diff ; Integer segPrefixBits = networkPrefixLength == null ? null : getSegmentPrefixLength ( originalDivBitSize , networkPrefixLength - bitsSoFar ) ; S div = groupingCreator . createDivision ( divLowerValue , divUpperValue , originalDivBitSize , radix , network , segPrefixBits ) ; divs [ bitDivSize - i - 1 ] = div ; if ( segBits == 0 && i > 0 ) { seg = getDivision ( ++ currentSegmentIndex ) ; segLowerVal = seg . getDivisionValue ( ) ; segUpperVal = seg . getUpperDivisionValue ( ) ; segBits = seg . getBitCount ( ) ; } break ; } else { int diff = divBitSize - segBits ; divLowerValue |= segLowerVal << diff ; divUpperValue |= segUpperVal << diff ; divBitSize = diff ; seg = getDivision ( ++ currentSegmentIndex ) ; segLowerVal = seg . getDivisionValue ( ) ; segUpperVal = seg . getUpperDivisionValue ( ) ; segBits = seg . getBitCount ( ) ; } } bitsSoFar += originalDivBitSize ; } return divs ; }
@param bitsPerDigit
@param network can be null if networkPrefixLength is null
@param networkPrefixLength
@param groupingCreator
@param groupingArrayCreator
@throws AddressValueException if bitsPerDigit is larger than 32
@return