Recalculates the size of the set.  Returns true if it's changed.
334222
private boolean recalculateSize() {
        int oldSize = size;
        size = 0;
        for (long elt : elements)
            size += Long.bitCount(elt);

        return size != oldSize;
    }
1121247
protected function _recalculate()
	{
		// calculate the number of pages
		$this->config['total_pages'] = (int) ceil($this->config['total_items'] / $this->config['per_page']) ?: 1;

		// get the current page number, either from the one set, or from the URI or the query string
		if ($this->config['current_page'])
		{
				$this->config['calculated_page'] = $this->config['current_page'];
		}
		else
		{
			if (is_string($this->config['uri_segment']))
			{
				$this->config['calculated_page'] = \Input::get($this->config['uri_segment'], 1);
			}
			else
			{
				$this->config['calculated_page'] = (int) \Request::main()->uri->get_segment($this->config['uri_segment']);
			}
		}

		// make sure the current page is within bounds
		if ($this->config['calculated_page'] > $this->config['total_pages'])
		{
			$this->config['calculated_page'] = $this->config['total_pages'];
		}
		elseif ($this->config['calculated_page'] < 1)
		{
			$this->config['calculated_page'] = 1;
		}

		// the current page must be zero based so that the offset for page 1 is 0.
		$this->config['offset'] = ($this->config['calculated_page'] - 1) * $this->config['per_page'];
	}
473375
public function RecalculateBasket()
    {
        $this->totalCostKnown = true;
        ++$this->recalculationDepth;

        $this->SetBasketRecalculationFlag(false);
        $this->dCostArticlesTotal = 0;
        $this->dCostArticlesTotalAfterDiscounts = 0;
        $this->dCostArticlesTotalAfterDiscountsWithoutNoneSponsoredVouchers = 0;
        $this->dCostShipping = 0;
        $this->dCostWrapping = 0;
        $this->dCostWrappingCards = 0;
        $this->dCostVouchers = 0;
        $this->dCostDiscounts = 0;
        $this->dCostVAT = 0;
        $this->dCostTotal = 0;
        $this->dCostPaymentMethodSurcharge = 0;

        $this->GetBasketArticles()->Refresh();
        $this->ResetAllShippingMarkers();

        $this->iTotalNumberOfUniqueArticles = $this->GetBasketArticles()->Length();
        $this->dTotalNumberOfArticles = $this->GetBasketArticles()->dNumberOfItems;
        $this->dCostArticlesTotal = $this->GetBasketArticles()->dProductPrice;
        $this->dTotalWeight = $this->GetBasketArticles()->dTotalWeight;
        $this->dTotalVolume = $this->GetBasketArticles()->dTotalVolume;

        $this->RecalculateDiscounts();
        $this->dCostArticlesTotalAfterDiscounts = $this->dCostArticlesTotal - $this->dCostDiscounts;
        $this->dCostArticlesTotalAfterDiscountsWithoutNoneSponsoredVouchers = $this->dCostArticlesTotalAfterDiscounts;

        /*
         * Reload vouchers so that their PostLoadHook is executed. If the user changed the currency, it needs to be
         * adjusted in the vouchers, which is done automatically in the hook. This is a quick fix - the problem itself
         * needs to be addressed in a wider scope.
         */
        $this->reloadVouchers();

        // now calculate the voucher values that act as discounts (vouchers NOT sponsored)
        $this->RecalculateNoneSponsoredVouchers();
        $this->dCostArticlesTotalAfterDiscounts = $this->dCostArticlesTotalAfterDiscounts - $this->dCostNoneSponsoredVouchers;

        $this->RecalculateShipping();
        $this->CalculatePaymentMethodCosts();

        $this->RecalculateVAT();
        $this->dCostTotal = $this->dCostArticlesTotalAfterDiscounts + $this->dCostShipping + $this->dCostPaymentMethodSurcharge;
        $this->RecalculateVouchers();
        $this->dCostTotal = $this->dCostTotal - $this->dCostVouchers; // - $this->dCostDiscounts;
        $this->dCostTotalWithoutShipping = $this->dCostTotal - $this->dCostShipping;

        /**
         * since the payment method may have a basket value restriction, we need to check its validity again after
         * we have the final basket value. If the final basket value invalidates the payment, then we need to call the recalculate again
         * if this again results in an invalid payment method, then we throw an exception.
         */
        $this->totalCostKnown = false;

        if (null !== $this->GetActivePaymentMethod() && false === $this->HasValidPaymentMethod()) {
            if ($this->recalculationDepth > 1) {
                throw new ErrorException("there is no shipping group that has any payment methods available for the current basket due to basket value ({$this->dCostTotal}) constraints set in payment methods [{$this->GetActivePaymentMethod()->id}]", 0, E_USER_ERROR, __FILE__, __LINE__);
            }
            $this->SetActiveShippingGroup(null);
            $this->oActivePaymentMethod = null;
            $this->GetActiveShippingGroup();
            $this->RecalculateBasket();
        }
        --$this->recalculationDepth;
    }
506303
public function reCalculateDimensions()
    {
        $this->log("Re-calculate image dimensions, newWidth x newHeigh was: " . $this->newWidth . " x " . $this->newHeight);

        $this->newWidth  = $this->newWidthOrig;
        $this->newHeight = $this->newHeightOrig;
        $this->crop      = $this->cropOrig;

        $this->initDimensions()
             ->calculateNewWidthAndHeight();

        return $this;
    }
297520
private static <T> void shrinkSet(final Set<T> set, int newSize) {
    if (!(set instanceof LinkedHashSet))
      throw new IllegalStateException("Cannot shrink a set which is not of type LinkedHashSet");
    if (newSize > set.size())
      throw new IllegalStateException("Cannot shrink a set of size " + set.size() + " to new size " + newSize);
    Iterator<T> entryIterator = set.iterator();
    int count = 0;
    while (count < newSize) {
      entryIterator.next();
      count++;
    }
    while (entryIterator.hasNext()) {
      entryIterator.next();
      entryIterator.remove();
    }
  }
1115401
def calculate_size(name, items):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += INT_SIZE_IN_BYTES
    for items_item in items:
        data_size += calculate_size_data(items_item)
    return data_size
154754
public void recalculateMeta() {
        data.yDataType = null;
        data.xDataTypes.clear();
        for(Record r : values()) {
            updateMeta(r);
        }
    }
959668
protected boolean incrementPoolSize(int expectingMaxSize) {

        Integer maxSize = null;
        long currentOverflowPoolSize;
        try {
            lock.lockInterruptibly();
            int currentMaxSize = poolAdapter.getMaxPoolSize();
            boolean incrementMaxPoolSize = currentMaxSize < maxOverflowPoolSize;
            if (currentMaxSize > expectingMaxSize) {
                LOGGER.info("Pool size changed by other thread, expected {} and actual value {}", expectingMaxSize, currentMaxSize);
                return incrementMaxPoolSize;
            }
            if (!incrementMaxPoolSize) {
                return false;
            }
            currentOverflowPoolSize = overflowPoolSize.incrementAndGet();
            poolAdapter.setMaxPoolSize(++currentMaxSize);
            maxSize = currentMaxSize;
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            return false;
        } finally {
            lock.unlock();
        }
        LOGGER.info("Pool size changed from previous value {} to {}", expectingMaxSize, maxSize);
        maxPoolSizeHistogram.update(maxSize);
        overflowPoolSizeHistogram.update(currentOverflowPoolSize);
        return true;
    }
714686
@Override
	protected void sizeChanged () {
		lastText = null; // Cause calculateOffsets to recalculate the line breaks.

		// The number of lines showed must be updated whenever the height is updated
		BitmapFont font = style.font;
		Drawable background = style.background;
		float availableHeight = getHeight() - (background == null ? 0 : background.getBottomHeight() + background.getTopHeight());
		linesShowing = (int) Math.floor(availableHeight / font.getLineHeight());
	}
172167
public function calculateChangeSet()
    {
        $set = [];
        foreach ($this->current as $key => $current) {
            $original = isset($this->original[$key]) ? $this->original[$key] : null;
            $set[$key]['old'] = $original;
            $set[$key]['new'] = $current;
        }
        foreach ($this->remove as $key) {
            $set[$key]['old'] = $this->original[$key];
            $set[$key]['new'] = null;
        }
        ksort($set);
        return $set;
    }
266066
def calculate_size(name, new_value):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += LONG_SIZE_IN_BYTES
    return data_size
553964
public boolean retainAll(CompactIntSet ints) {
        int oldSize = size();
        bitSet.and(ints.bitSet);
        return oldSize != size();
    }
561579
public int size()
    {
        int ret = 0;
        for(Collection<T> series : data)
        {
            if(series.size() > 0)
                ++ret;
        }
        return ret;

    }
1044486
int adjustPoolSize(int poolSize, int poolAdjustment) {
        if (threadPool == null)
            return poolSize; // arguably should return 0, but "least change" is safer... This happens during shutdown.

        int newPoolSize = poolSize + poolAdjustment;
        lastAction = LastAction.NONE;

        if (poolAdjustment != 0) {
            // don't shrink below coreThreads
            if (poolAdjustment < 0 && newPoolSize >= coreThreads) {
                lastAction = LastAction.SHRINK;
                setPoolSize(newPoolSize);
            } else if (poolAdjustment > 0 && newPoolSize <= maxThreads) {
                lastAction = LastAction.GROW;
                setPoolSize(newPoolSize);
            } else {
                newPoolSize = poolSize;
            }
        }

        return newPoolSize;
    }
286141
def itemsize_bits(self):
        """"""
        if self.dtype is not None:
            return self.dtype.itemsize * 8
        else:
            return sum(x[1] for x in self.format)
1271271
def itemsize(self):
        
        return self._items[:self._count, 1] - self._items[:self._count, 0]
350382
@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		if (w != oldw || h != oldh) {
			mNeedsResize = true;
		}
	}