forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontains.as
More file actions
28 lines (25 loc) · 680 Bytes
/
contains.as
File metadata and controls
28 lines (25 loc) · 680 Bytes
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
package utils.array
{
/**
Finds out how many instances of <code>item</code> Array contains.
@param inArray: Array to search for <code>item</code> in.
@param item: Object to find.
@return The amount of <code>item</code>'s found; if none were found returns <code>0</code>.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 7, 7, 7, 4, 5);
trace("numberArray contains " + ArrayUtil.contains(numberArray, 7) + " 7's.");
</code>
*/
public function contains(inArray:Array, item:*):uint
{
var i:int = inArray.indexOf(item, 0);
var t:uint = 0;
while (i != -1)
{
i = inArray.indexOf(item, i + 1);
t++;
}
return t;
}
}