FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CommentCoreLibrary/src/Array.js at master · fpg100/CommentCoreLibrary · GitHub
fpg100
/
CommentCoreLibrary
Public
forked from
jabbany/CommentCoreLibrary
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
CommentCoreLibrary
/
src
/
Array.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (45 loc) · 960 Bytes
Breadcrumbs
CommentCoreLibrary
/
src
/
Array.js
Copy path
File metadata and controls
45 lines (45 loc) · 960 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Binary Search Stubs for JS Arrays
*
@license
MIT
*
@author
Jim Chen
*/
var
BinArray
=
(
function
(
)
{
var
BinArray
=
{
}
;
BinArray
.
bsearch
=
function
(
arr
,
what
,
how
)
{
if
(
arr
.
length
===
0
)
{
return
0
;
}
if
(
how
(
what
,
arr
[
0
]
)
<
0
)
{
return
0
;
}
if
(
how
(
what
,
arr
[
arr
.
length
-
1
]
)
>=
0
)
{
return
arr
.
length
;
}
var
low
=
0
;
var
i
=
0
;
var
count
=
0
;
var
high
=
arr
.
length
-
1
;
while
(
low
<=
high
)
{
i
=
Math
.
floor
(
(
high
+
low
+
1
)
/
2
)
;
count
++
;
if
(
how
(
what
,
arr
[
i
-
1
]
)
>=
0
&&
how
(
what
,
arr
[
i
]
)
<
0
)
{
return
i
;
}
if
(
how
(
what
,
arr
[
i
-
1
]
)
<
0
)
{
high
=
i
-
1
;
}
else
if
(
how
(
what
,
arr
[
i
]
)
>=
0
)
{
low
=
i
;
}
else
{
console
.
error
(
'Program Error'
)
;
}
if
(
count
>
1500
)
{
console
.
error
(
'Too many run cycles.'
)
;
}
}
return
-
1
;
// Never actually run
}
;
BinArray
.
binsert
=
function
(
arr
,
what
,
how
)
{
var
index
=
BinArray
.
bsearch
(
arr
,
what
,
how
)
;
arr
.
splice
(
index
,
0
,
what
)
;
return
index
;
}
;
return
BinArray
;
}
)
(
)
;
Back
|
FazBrowse Home
|
New Git URL