hi guys
i'm looking for a way of removing duplicate items in an array
i've done this so far
//sort array so all items of the same content are grouped together
myArray.sort();
//loop through items, removing any sitting next to a duplicate
for (var i:Number = 0; i myArray.length; i++) {
Don't you think that you should take into consideration that the
length of the array can change during the loop?
Attila
ABER //loop through items, removing any sitting next to a duplicate
ABER for (var i:Number = 0; i myArray.length; i++) {
ABER if (myArray[i] == myArray[i+1]) {
ABER
You could prevent duplicates from being placed into the array in the first
place. Or
http://proto.layer51.com/d.aspx?f=1196
You could rewrite a prototype as a regular function that takes the array as
an argument.
- eric
On 5/22/07, Allandt Bik-Elliott (Receptacle) [EMAIL PROTECTED]
wrote:
hi
To: flashcoders
Subject: [Flashcoders] remove duplicate items in array
hi guys
i'm looking for a way of removing duplicate items in an array
i've done this so far
//sort array so all items of the same content are grouped together
myArray.sort();
//loop through items, removing any sitting next
From my XArray mixin class (all 3 are needed).
/**
* Returns a new array by removing duplicate values in Array.
*/
Array.prototype.uniq = function()
{
var r = [];
var l = this.length;
for (var a = 0; a l; a++) {
if (!r.has(this[a])) r.push(this[a]);
yeh - i started trying to do that but just got myself into a moody
bluddle - i'll prolly go back and try to rewrite it a bit cleaner
when i'm happy i'll hit deadline
here's what i ended up with -
var myTempArray:Array = [];
8o
thankyou
On 22 May 2007, at 18:56, Steven Sacks wrote:
From my XArray mixin class (all 3 are needed).
/**
* Returns a new array by removing duplicate values in Array.
*/
Array.prototype.uniq = function()
{
var r = [];
var l = this.length;
for (var a = 0; a l;
i could barely read that - it looks ammmaaazing :D
thanks eric - when's the next super samurai book coming out? :)
On 22 May 2007, at 18:18, eric e. dolecki wrote:
You could prevent duplicates from being placed into the array in
the first
place. Or
http://proto.layer51.com/d.aspx?f=1196
holy wow - super samurai ;)
I didn't know many even saw that one...
On 5/22/07, Allandt Bik-Elliott (Receptacle) [EMAIL PROTECTED]
wrote:
i could barely read that - it looks ammmaaazing :D
thanks eric - when's the next super samurai book coming out? :)
On 22 May 2007, at 18:18, eric e.
i had to order it from the states - it was great
On 22 May 2007, at 19:58, eric e. dolecki wrote:
holy wow - super samurai ;)
I didn't know many even saw that one...
On 5/22/07, Allandt Bik-Elliott (Receptacle)
[EMAIL PROTECTED]
wrote:
i could barely read that - it looks ammmaaazing :D
10 matches
Mail list logo