Rich Manalang wrote:
> It is sorted, but it's an array of objects.  Is there a way to hash an 
> object?

I guess a better question would be how do you determine object A is 
equal object B. Because if it is sorted, it would be much faster to walk 
the array and copy any element that is not the same as the last one you 
copied.

-Steve

> On 12/20/06, *Christof Donat* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> 
> wrote:
> 
>     Hi,
> 
>      > Anyone know of a fast way to remove dups in an array?
> 
>     Is the array sorted? Then you can do
> 
>     function arrayUniq(a) {
>             var rval = [a[0]];
>             var o = a[0];
>             for( var i = 1; i < a.length; i++ ) if( a[i] != o ) {
>                     rval.push (a[i]);
>                     o = a[i];
>             }
>             return rval;
>     }
> 
>     Christof
> 
>     _______________________________________________
>     jQuery mailing list
>     discuss@jquery.com <mailto:discuss@jquery.com>
>     http://jquery.com/discuss/
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to