Constant Time ETS Ordered Set Get Largest-Keyed Member ?

Vladimir Sekissov svg@REDACTED
Fri Oct 24 21:35:54 CEST 2003


Good day,

What about

ets:lookup(Tab, ets:last(Key))

or

(catch ets:foldr(fun (Last, _) -> throw(Last) end, [], Tab))

Best Regards,
Vladimir Sekissov

enewhuis> O Great ETS Masters,
enewhuis> 
enewhuis> Is there a "constant time" ETS ordered set get largest-keyed member 
enewhuis> function, technique, or trick?
enewhuis> 
enewhuis> I want to retreive the last member of the ordered set, the one with the 
enewhuis> largest valued key, often enough to justify building a separate ETS 
enewhuis> index table.  My code would be simpler, however, of course, if I could 
enewhuis> avoid the extra ETS table.
enewhuis> 
enewhuis> In C++, with a heavy dose of the Standard C++ Library containers, I'd 
enewhuis> probably do this with the "reverse end" member of a map<>.
enewhuis> 
enewhuis> Sincerely,
enewhuis> Eric Newhuis
enewhuis> 
enewhuis> 



More information about the erlang-questions mailing list