El viernes, 21 de febrero de 2014 07:49:27 UTC-6, David P. Sanders escribió: > > Hi, > > Suppose I have a collection of elements that I will create once at the > beginining, visit in an unknown order and delete one by one when they are > visited. > What is the most efficient data structure for this in julia? > > I believe this would be an unordered_set (C++) or HashSet (java?), i.e. a > Set implemented via a dictionary. (But I am not a computer scientist, so > please correct me if I am wrong!) > Should I in fact, then, just use a "Set" in julia? > > If, instead, I can add *and* remove elements in a "random" way, is the > answer the same? >
OK, I think I have answered my own question: a Set is the good structure. And to create a set from an array I can do something like s = Set([3, 4, 5]...) or s = Set([i*2 for i in 1:5]...) which would be the closest thing to a set comprehension? (The ellipsis is necessary, otherwise a set with a single array object inside is created.) Thanks, David. > > Thanks, > David. >
