# Unique List?

**URL:** <https://forum.kirupa.com/t/unique-list/282444>\
**Category:** flash\
**Created:** [February 22, 2009, 6:27am UTC](https://forum.kirupa.com/t/unique-list/282444 "2009-02-22T06:27:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BeerOclock](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@BeerOclock](https://forum.kirupa.com/u/BeerOclock)\
**Post date:** [February 22, 2009, 6:27am UTC](https://forum.kirupa.com/t/unique-list/282444/1 "2009-02-22T06:27:55Z")

</div>

I need a data structure thats like an Array, except it only holds unique entries.

For example:

```auto

var a:Sprite = new Sprite();
var b:Sprite = new Sprite();

pushUnique(a);
pushUnique(b);
pushUnique(a);

```

Now the list should contain only 2 items (not 3!).

I can easily implement pushUnique() like this:

```auto

function pushUnique(o:Object):void {
var isIn:Boolean = false;
for (i=0; i<theList.length; i++) {
if (theList* == o)
  isIn = true;
}
if (!isIn)
 theList.push(o);

```

However, I think this will be very slow once the list gets big, and I’m wondering if there is a smarter way to do this, or if there is already a built in datastructure that does it…
