Example #1
0
	void Insert(FreedBlock* freedBlock)
	{
		const size_t sizeClass = SizeClass(freedBlock->Size());
		m_rangeLists[sizeClass].Insert<AddressOrder>(freedBlock);

		m_bitmap |= Bit<uintptr_t>(sizeClass);
	}
Example #2
0
	void Remove(FreedBlock* freedBlock)
	{
		const size_t sizeClass = SizeClass(freedBlock->Size());
		m_rangeLists[sizeClass].Remove(freedBlock);

		// (masking with !IsEmpty() << sizeClass would probably be faster)
		if(m_rangeLists[sizeClass].IsEmpty())
			m_bitmap &= ~Bit<uintptr_t>(sizeClass);
	}
Example #3
0
	/**
	 * @return the first freed block of size >= minSize or 0 if none exists.
	 **/
	FreedBlock* Find(size_t minSize)
	{
		// iterate over all large enough, non-empty size classes
		// (zero overhead for empty size classes)
		const size_t minSizeClass = SizeClass(minSize);
		size_t sizeClassBits = m_bitmap & ((~size_t(0)) << minSizeClass);
		while(sizeClassBits)
		{
			const size_t size = ValueOfLeastSignificantOneBit(sizeClassBits);
			sizeClassBits &= ~size;	// remove from sizeClassBits
			const size_t sizeClass = SizeClass(size);

			FreedBlock* freedBlock = m_rangeLists[sizeClass].Find(minSize);
			if(freedBlock)
				return freedBlock;
		}

		// apparently all classes above minSizeClass are empty,
		// or the above would have succeeded.
		ENSURE(m_bitmap < Bit<uintptr_t>(minSizeClass+1));
		return 0;
	}
Example #4
0
void QgsDataDefinedSizeLegend::updateFromSymbolAndProperty( const QgsMarkerSymbol *symbol, const QgsProperty &ddSize )
{
  mSymbol.reset( symbol->clone() );
  mSymbol->setDataDefinedSize( QgsProperty() );  // original symbol may have had data-defined size associated

  const QgsSizeScaleTransformer *sizeTransformer = dynamic_cast< const QgsSizeScaleTransformer * >( ddSize.transformer() );
  mSizeScaleTransformer.reset( sizeTransformer ? sizeTransformer->clone() : nullptr );

  if ( mTitleLabel.isEmpty() )
    mTitleLabel = ddSize.propertyType() == QgsProperty::ExpressionBasedProperty ? ddSize.expressionString() : ddSize.field();

  // automatically generate classes if no classes are defined
  if ( sizeTransformer && mSizeClasses.isEmpty() )
  {
    mSizeClasses.clear();
    Q_FOREACH ( double v, QgsSymbolLayerUtils::prettyBreaks( sizeTransformer->minValue(), sizeTransformer->maxValue(), 4 ) )
    {
      mSizeClasses << SizeClass( v, QString::number( v ) );
    }
  }