Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Crac Utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Environments
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gbooking
Crac Utils
Commits
fbc69175
Commit
fbc69175
authored
6 years ago
by
swvitaliy
Browse files
Options
Downloads
Patches
Plain Diff
Rename zeroBitset -> busyBitSet; add freeBitset
parent
6e00e2cd
Branches
Branches containing commit
Tags
v1.2.5
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
package.json
+1
-1
1 addition, 1 deletion
package.json
src/index.js
+4
-4
4 additions, 4 deletions
src/index.js
src/vector.js
+15
-6
15 additions, 6 deletions
src/vector.js
with
20 additions
and
11 deletions
package.json
+
1
−
1
View file @
fbc69175
{
"name"
:
"crac-utils"
,
"version"
:
"1.2.
4
"
,
"version"
:
"1.2.
5
"
,
"description"
:
"The GBooking crac-utils library"
,
"main"
:
"dist/cjs/index.js"
,
"scripts"
:
{
...
...
This diff is collapsed.
Click to expand it.
src/index.js
+
4
−
4
View file @
fbc69175
import
{
defaultVectorSlotSize
,
zero
BitSets
,
bitsetStrToInt32Array
,
prepar
eBit
s
et
,
new
Zero
Bitset
,
setAnd
,
setUnion
,
iterateCRACVector
,
getCRACFreeSlots
}
from
"
./vector
"
;
import
{
defaultVectorSlotSize
,
busy
BitSets
,
fre
eBit
S
et
s
,
new
Busy
Bitset
,
newFreeBitset
,
bitsetStrToInt32Array
,
prepareBitset
,
setAnd
,
setUnion
,
iterateCRACVector
,
getCRACFreeSlots
}
from
"
./vector
"
;
import
{
makeSlots
,
calculateWorkloadWeights
,
getFirstLastMinutes
,
isSlotAvailable
}
from
'
./utils
'
;
export
{
// export from vector
defaultVectorSlotSize
,
zeroBitSets
,
bitsetStrToInt32Array
,
prepareBitset
,
newZeroBitset
,
setAnd
,
setUnion
,
iterateCRACVector
,
getCRACFreeSlots
,
defaultVectorSlotSize
,
busyBitSets
,
freeBitSets
,
newBusyBitset
,
newFreeBitset
,
bitsetStrToInt32Array
,
prepareBitset
,
setAnd
,
setUnion
,
iterateCRACVector
,
getCRACFreeSlots
,
// export from utils
makeSlots
,
calculateWorkloadWeights
,
getFirstLastMinutes
,
isSlotAvailable
};
This diff is collapsed.
Click to expand it.
src/vector.js
+
15
−
6
View file @
fbc69175
...
...
@@ -3,7 +3,7 @@
export
const
minutesInDay
=
1440
;
export
const
defaultVectorSlotSize
=
5
;
export
const
zero
BitSets
=
{
export
const
busy
BitSets
=
{
5
:
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
1
:
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
...
...
@@ -14,6 +14,11 @@ export const zeroBitSets = {
]
};
export
const
freeBitSets
=
{
5
:
busyBitSets
[
5
].
map
(
num
=>
~
num
),
0
:
busyBitSets
[
0
].
map
(
num
=>
~
num
),
};
/**
* Convert string bitset into int32 array
* @param str bitset in string representation
...
...
@@ -44,8 +49,12 @@ export function prepareBitset(bitset, vectorSlotSize) {
return
(
typeof
bitset
===
"
string
"
)
?
bitsetStrToInt32Array
(
bitset
,
vectorSlotSize
)
:
bitset
;
}
export
function
newZeroBitset
(
vectorSlotSize
)
{
return
zeroBitSets
[
vectorSlotSize
].
slice
();
export
function
newBusyBitset
(
vectorSlotSize
)
{
return
busyBitSets
[
vectorSlotSize
].
slice
();
}
export
function
newFreeBitset
(
vectorSlotSize
)
{
return
freeBitSets
[
vectorSlotSize
].
slice
();
}
/**
...
...
@@ -111,11 +120,11 @@ export function iterateCRACVector(bitset, fn, offset, end) {
* Таким образом, чтобы вычислить свободный слот, нужно время начала умножить на cracTimeUnit.
*
* @param bitset CRAC вектор
* @param
vectorS
lotSize
к
оличество битов в слоте
* @param [offset=0]
с
мещение в CRAC векторе, считаемое в количестве бит
* @param
s
lotSize
К
оличество битов в слоте
* @param [offset=0]
С
мещение в CRAC векторе, считаемое в количестве бит
* @returns {Array}
*/
export
function
getCRACFreeSlots
(
bitset
,
vectorS
lotSize
,
offset
=
0
)
{
export
function
getCRACFreeSlots
(
bitset
,
s
lotSize
,
offset
=
0
)
{
let
freeSlots
=
[];
let
slotLen
=
0
;
let
slotOffset
=
-
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment