-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
loanObject:#
IDs to cantor paired ints [MA-156]
- Loading branch information
Showing
3 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Helpers; | ||
|
||
class Util | ||
{ | ||
public const COLLECTION_OBJECT = 1; | ||
public const LOAN_OBJECT = 2; | ||
|
||
/** | ||
* Generate a unique ID based on a combination of two numbers. | ||
* @param int $x | ||
* @param int $y | ||
* @return int | ||
*/ | ||
public static function cantorPair($x, $y) | ||
{ | ||
return (($x + $y) * ($x + $y + 1)) / 2 + $y; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters