# Small, indexable, unique, and statically-sized immutable arrays

**URL:** https://discourse.julialang.org/t/small-indexable-unique-and-statically-sized-immutable-arrays/6559
**Category:** General Usage
**Tags:** question
**Created:** [October 19, 2017, 12:51pm UTC](https://discourse.julialang.org/t/small-indexable-unique-and-statically-sized-immutable-arrays/6559 "2017-10-19T12:51:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [October 19, 2017, 12:51pm UTC](https://discourse.julialang.org/t/small-indexable-unique-and-statically-sized-immutable-arrays/6559/1 "2017-10-19T12:51:18Z")

</div>

I might be over-thinking this and I know I’m getting greedy here:

Is there an array type that is indexable, has only unique members, can not change in size or elements, and is relatively “small” (i.e. shorter than say 256)? The element type of this array will be `String`.

I will need to refer to the elements in these arrays and think that using a `Int` pointer might be cheaper than the actual `String` it’s pointed at (correct me if I’m wrong). These array should not contain duplicate elements, and once created should not change in size, nor should their elements change.

- [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) and [ImmutableArrays.jl](https://github.com/JuliaGeometry/ImmutableArrays.jl) is not unique.
- `Set` is not statically sized nor is it indexable.

I can solve all of this with some checks and controls. For instance:

```julia
using StaticArrays
v(x::Vector{String}) = SVector(unique(x)...)

```

but it would be neat if this was baked into the type itself… Any ideas?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [October 19, 2017, 2:01pm UTC](https://discourse.julialang.org/t/small-indexable-unique-and-statically-sized-immutable-arrays/6559/2 "2017-10-19T14:01:09Z")

</div>

Wrap `StaticVector` in an immutable (with appropriate parameters), enforce uniqueness in the inner constructor.

---

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [October 19, 2017, 4:23pm UTC](https://discourse.julialang.org/t/small-indexable-unique-and-statically-sized-immutable-arrays/6559/3 "2017-10-19T16:23:22Z")

</div>

Actually, now that I think about it, maybe just a `Tuple` without the replicates. Cause I don’t need all the math behind `StaticArrays`.
