On Monday, May 18, 2015 at 5:31:18 PM UTC-4, Yichao Yu wrote:
>
> On Mon, May 18, 2015 at 5:24 PM, Scott Jones <scott.pa...@gmail.com 
> <javascript:>> wrote: 
> > I suppose I could use a set simply to determine if it was present or 
> not, 
> > and then push! to another array if not present... just didn't seem as 
> > efficient as what I'm used to... 
>
> Why does it have to be an array? And what data structure do you use in 
> other languages? 
>

In COS (CachéObjectScript... i.e. 21st century Mumps), I would have written 
something like:

If '$data(arr(key),index) { // If the array already has the key, it is set 
into the variable index, otherwise:
    Set arr(key) = $Increment(index) // atomically increment index, and set 
the key to that value in the array
}
// Do whatever I want with the index (usually I also set up a reverse 
mapping, i.e.:
Set index(index) = key

The nice thing in COS, all I have to do to make that persistent, and shared 
across a system (or also distributed to other systems), is add a "^" before 
the arrays or values...
`^arr(key)` and `$increment(^index)` and `^index(^index)`.
Very very fast too...
    

> > 
> > On Monday, May 18, 2015 at 4:53:02 PM UTC-4, Jameson wrote: 
> >> 
> >> use a Set? 
> >> http://docs.julialang.org/en/latest/stdlib/collections/?highlight=set 
> >> 
> >> On Mon, May 18, 2015 at 4:46 PM Scott Jones <scott.pa...@gmail.com> 
> wrote: 
> >>> 
> >>> I would like to be able to do the following in Julia: 
> >>> Take a UInt64 (or UInt128, for that matter), and add it to an array, 
> if 
> >>> it is not already present, returning the index. 
> >>> (This would be trivial in the language I used to work on, and I think 
> it 
> >>> probably is in Julia as well, but I haven't found the right data 
> structure 
> >>> yet...) 
> >>> What would be the best performing way of handling that? 
> >>> What if, instead of an UInt64 or UInt128, I had an array of bytes 
> (like 
> >>> 128 or 256)?  What would be the best way for that? 
> >>> 
> >>> Thanks, Scott 
>

Reply via email to