Fill a tiles distribution randomly within a grid.

@param Grid $grid Grid to fill.
@param Distribution $distribution Distribution to set.
@return void
@throws InvalidArgumentException If there is no spot available for the given tile in the grid.
506487
public static function tryToFill(Grid $grid, Distribution $distribution)
    {
        $smallTiles = $distribution->small;
        $tallTiles = $distribution->tall;
        $wideTiles = $distribution->wide;

        for ($i = 0; $i < $distribution->getTiles(); $i++) {
            // Fill small tiles at the end
            if ($wideTiles === 0 && $tallTiles === 0) {
                static::set($grid, Tile::SMALL());
                $smallTiles -= 1;
            // Fill tall tiles if more or equal than wide ones
            } elseif ($tallTiles >= $wideTiles) {
                static::set($grid, Tile::TALL());
                $tallTiles -= 1;
            // Fill wide tiles if more than tall ones
            } else {
                static::set($grid, Tile::WIDE());
                $wideTiles -= 1;
            }
        }
    }
266556
public function setPath(string $path): void
    {
        if (!file_exists($path) || !is_dir($path)) {
            throw new InvalidArgumentException(
                'Expected the template path to be an existing directory, received: ' . $path
            );
        }

        $this->path = $path;
    }
745802
public function setLine($line)
    {
        if ( ! is_string($line))
        {
            throw new InvalidArgumentException(
                'Expected a string, but got '.gettype($line)
            );
        }

        $this->line = $line;
    }
1183754
public function process (ContainerBuilder $container)
    {
        if (!$container->hasDefinition('thrace_data_grid.provider')) {
            return;
        }
                
        $definition = $container->getDefinition('thrace_data_grid.provider');
        
        $dataGrids = array();
        
        foreach ($container->findTaggedServiceIds('thrace_data_grid.datagrid') as $id => $tags) {
            foreach ($tags as $attributes) {
                if (empty($attributes['alias'])) {
                    throw new \InvalidArgumentException(
                        sprintf('The alias is not defined in the "thrace_data_grid.datagrid" tag for the service "%s"', $id)
                    );
                }
                
                $dataGrids[$attributes['alias']] = $id;
            }
        }
        
        $definition->replaceArgument(1, $dataGrids);
    }
922588
public function setDir($dir)
    {
        if (in_array($dir, Direction::asArray(), true) === true) {
            $this->dir = $dir;
        } else {
            $msg = "The 'dir' argument must be a value from the Direction enumeration.";
            throw new InvalidArgumentException($msg);
        }
    }
846524
protected function assertEmptyTileSlot($row, $column, Tile $tile)
    {
        // Check indexes
        $this->assertIndexesAreValidForTile($row, $column, $tile);

        // Check all cells are empty
        if (!$this->isEmptyForTile($row, $column, $tile)) {
            throw new InvalidArgumentException(
                "Cannot set tile {$tile} at [$row, $column]: not empty."
            );
        }
    }
15371
public function setTile(SwatTile $tile)
    {
        // if we're overwriting an existing tile, remove it's parent link
        if ($this->tile !== null) {
            $this->tile->parent = null;
        }

        $this->tile = $tile;
        $tile->parent = $this;
    }
614333
public function fit(array $values) : void
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Strategy must be fit with'
                . ' at least 1 value.');
        }

        $this->percentile = Stats::percentile($values, $this->p);
        $this->mad = Stats::mad($values) ?: EPSILON;
    }
984343
public function setDivision($division)
    {

        if (!is_null($division) && ($division > 7)) {
            throw new \InvalidArgumentException('invalid value for $division when calling GetCorporationsCorporationIdDivisionsWallet., must be smaller than or equal to 7.');
        }
        if (!is_null($division) && ($division < 1)) {
            throw new \InvalidArgumentException('invalid value for $division when calling GetCorporationsCorporationIdDivisionsWallet., must be bigger than or equal to 1.');
        }

        $this->container['division'] = $division;

        return $this;
    }
91546
public void addConfiguredDistributer(final DistributerDef distributer) {
    if (distributer == null) {
      throw new NullPointerException("distributer");
    }
    distributer.setProject(getProject());
    this.distributers.addElement(distributer);
  }
226329
public function setValues($values)
    {
        if ((null !== $values) && (false === is_array($values))) {
            if (false === ($values instanceof ArrayAccess)) {
                throw new InvalidArgumentException(
                    'The value of $values is not an array or an instance of ArrayAccess.'
                );
            }
        }

        $this->values = $values;
    }
780562
public function setAdaptive($adaptive)
    {
        if (is_bool($adaptive)) {
            $this->adaptive = $adaptive;
        } else {
            $msg = "The adaptive argument must be a boolean, '" . gettype($adaptive) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
979127
@Bean
    @ConditionalOnMissingBean
    DistributionSetTagManagement distributionSetTagManagement(
            final DistributionSetTagRepository distributionSetTagRepository,
            final DistributionSetRepository distributionSetRepository,
            final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao,
            final JpaProperties properties) {
        return new JpaDistributionSetTagManagement(distributionSetTagRepository, distributionSetRepository,
                virtualPropertyReplacer, criteriaNoCountDao, properties.getDatabase());
    }
189504
@Override
	protected void putGridIntoCanonical(Grid g ) {
		// first put it into a plausible solution
		if( g.columns != numCols ) {
			rotateGridCCW(g);
		}

		if( isClockWise(g)) {
			flipHorizontal(g);
		}

		// pick the solutin which puts (0,0) coordinate the closest to the top left corner to resolve ambiguity
		if( g.columns == g.rows ) {
			closestCorner[0] = g.get(0,0).center.normSq();
			closestCorner[1] = g.get(numRows-1,0).center.normSq();
			closestCorner[2] = g.get(numRows-1,numCols-1).center.normSq();
			closestCorner[3] = g.get(0,numCols-1).center.normSq();

			int best = 0;
			for (int i = 0; i < 4; i++) {
				if( closestCorner[i] < closestCorner[best]) {
					best = i;
				}
			}

			for (int i = 0; i < best; i++) {
				rotateGridCCW(g);
			}
		} else {
			double d00 = g.get(0,0).center.normSq();
			double d11 = g.get(numRows-1,numCols-1).center.normSq();

			if( d11 < d00 ) {
				rotateGridCCW(g);
				rotateGridCCW(g);
			}
		}
	}
1099522
public function setMinPlays($minPlays)
    {
        if (is_int($minPlays) === true && $minPlays >= 0) {
            $this->minPlays = $minPlays;
        } else {
            $msg = "The 'minPlays' argument must be a positive (>= 0) integer, '" . gettype($minPlays) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
939371
public function createGrid($gridClassName)
    {
        $gridClass = new \ReflectionClass($gridClassName);

        /* @var \PedroTeixeira\Bundle\GridBundle\Grid\GridAbstract $grid */
        $grid = $gridClass->newInstance($this->container);
        $grid->setupGrid();

        return $grid;
    }
952057
public function initialize(Grid $grid)
    {
        $this->initializeComponent($grid);
        $this->provideFields();
        $this->listen(
            $this->grid->getConfig()->getDataProvider()
        );
        return null;
    }