Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tomáš Peterka
jio
Commits
700ef189
Commit
700ef189
authored
Aug 26, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReferenceArray.js added
parent
4a533092
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
0 deletions
+87
-0
src/jio/core/ReferenceArray.js
src/jio/core/ReferenceArray.js
+87
-0
No files found.
src/jio/core/ReferenceArray.js
0 → 100644
View file @
700ef189
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global */
/**
* An array that contain object (or array) references.
*
* @class ReferenceArray
* @constructor
* @param {array} [array] The array where to work on
*/
function
ReferenceArray
(
array
)
{
if
(
Array
.
isArray
(
array
))
{
this
.
_array
=
array
;
}
else
{
this
.
_array
=
[];
}
}
/**
* Returns the array version of the job queue
*
* @method asArray
* @return {Array} The job queue as array
*/
ReferenceArray
.
prototype
.
asArray
=
function
()
{
return
this
.
_array
;
};
/**
* Returns the index of the object
*
* @method indexOf
* @param {Object} object The object to search
*/
ReferenceArray
.
prototype
.
indexOf
=
function
(
object
)
{
var
i
;
for
(
i
=
0
;
i
<
this
.
_array
.
length
;
i
+=
1
)
{
if
(
this
.
_array
[
i
]
===
object
)
{
return
i
;
}
}
return
-
1
;
};
/**
* Put an object to the list. If an object already exists, do nothing.
*
* @method put
* @param {Object} object The object to add
*/
ReferenceArray
.
prototype
.
put
=
function
(
object
)
{
var
i
;
for
(
i
=
0
;
i
<
this
.
_array
.
length
;
i
+=
1
)
{
if
(
this
.
_array
[
i
]
===
object
)
{
return
false
;
}
}
this
.
_array
[
i
]
=
object
;
return
true
;
};
/**
* Removes an object from the list
*
* @method remove
* @param {Object} object The object to remove
*/
ReferenceArray
.
prototype
.
remove
=
function
(
object
)
{
var
i
;
for
(
i
=
0
;
i
<
this
.
_array
.
length
;
i
+=
1
)
{
if
(
this
.
_array
[
i
]
===
object
)
{
this
.
_array
.
splice
(
i
,
1
);
return
true
;
}
}
return
false
;
};
/**
* Clears the list.
*
* @method clear
*/
ReferenceArray
.
prototype
.
clear
=
function
()
{
this
.
_array
.
length
=
0
;
return
this
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment