Documentation

Iterator
in package

FinalYes

Iterator utility.

Table of Contents

Methods

duplicateCombinations()  : void
Duplicate combinations with duplicates - What was taken out once can be taken out again - The order in which the items are retrieved is meaningless (if the elements that make up the pair are the same, they are treated as the same even if they are in a different order) ```php \X\Util\Iterator::duplicateCombinations('abc', 2, 0, '', $return); var_export($return); // array ( // 0 => 'aa', // 1 => 'ab', // 2 => 'ac', // 3 => 'bb', // 4 => 'bc', // 5 => 'cc', // ) ```
duplicatePermutation()  : void
Permutations with duplicates.
unDuplicateCombinations()  : void
No duplicate combination.
unDuplicatePermutation()  : void
Non-duplicate permutation.

Methods

duplicateCombinations()

Duplicate combinations with duplicates - What was taken out once can be taken out again - The order in which the items are retrieved is meaningless (if the elements that make up the pair are the same, they are treated as the same even if they are in a different order) ```php \X\Util\Iterator::duplicateCombinations('abc', 2, 0, '', $return); var_export($return); // array ( // 0 => 'aa', // 1 => 'ab', // 2 => 'ac', // 3 => 'bb', // 4 => 'bc', // 5 => 'cc', // ) ```

public static duplicateCombinations(string $str, int $r[, int $start = 0 ][, string $progress = '' ][, array<string|int, mixed>|null &$return = [] ]) : void
Parameters
$str : string

Input string.

$r : int

String length of the result of the combination.

$start : int = 0

The position from which the input string is taken.

$progress : string = ''

String in progress.

$return : array<string|int, mixed>|null = []

Combination Results.

duplicatePermutation()

Permutations with duplicates.

public static duplicatePermutation(string $str, int $r[, string $progress = '' ][, array<string|int, mixed>|null &$return = [] ]) : void
  • An item taken out once can be taken out again.
  • The order in which the items are retrieved makes sense (even if the elements of a pair are the same, they are treated as different if they are in a different order).
\X\Util\Iterator::duplicatePermutation('abc', 2, '', $return);
var_export($return);
// array (
//   0 => 'aa',
//   1 => 'ab',
//   2 => 'ac',
//   3 => 'ba',
//   4 => 'bb',
//   5 => 'bc',
//   6 => 'ca',
//   7 => 'cb',
//   8 => 'cc'
// )
Parameters
$str : string

Input string.

$r : int

String length of the result of the combination.

$progress : string = ''

String in progress.

$return : array<string|int, mixed>|null = []

Combination Results.

unDuplicateCombinations()

No duplicate combination.

public static unDuplicateCombinations(string $str, int $r[, int $start = 0 ][, string $progress = '' ][, array<string|int, mixed>|null &$return = [] ]) : void
  • Once something is taken out once, it cannot be taken out again.
  • The order in which the items are taken out is meaningless (if the elements of a pair are the same, they are treated as the same even if they are taken out in a different order).
\X\Util\Iterator::unDuplicateCombinations('abc', 2, 0, '', $return);
var_export($return);
// array (
//   0 => 'ab',
//   1 => 'ac',
//   2 => 'bc',
// )
Parameters
$str : string

Input string.

$r : int

String length of the result of the combination.

$start : int = 0

The position from which the input string is taken.

$progress : string = ''

String in progress.

$return : array<string|int, mixed>|null = []

Combination Results.

Return values
void

unDuplicatePermutation()

Non-duplicate permutation.

public static unDuplicatePermutation(string $str, int $r[, string $progress = '' ][, array<string|int, mixed>|null &$return = [] ]) : void
  • Once retrieved cannot be retrieved again.
  • The order in which the items are taken out makes sense (even if the elements of a pair are the same, they are treated as different if they are taken out in a different order).
\X\Util\Iterator::unDuplicatePermutation('abc', 2, '', $return);
var_export($return);
// array (
//   0 => 'ab',
//   1 => 'ac',
//   2 => 'ba',
//   3 => 'bc',
//   4 => 'ca',
//   5 => 'cb',
// )
Parameters
$str : string

Input string.

$r : int

String length of the result of the combination.

$progress : string = ''

String in progress.

$return : array<string|int, mixed>|null = []

Combination Results.


        
On this page

Search results