[erlang-questions] Best way to test if empty dict/set/etc.?
Fri May 31 10:15:20 CEST 2013
On 05/31/2013 09:03 AM, Vance Shipley wrote:
} With gb_trees and gb_sets size/1 is O(1). These opaque data structures
} happen to be tuples where the first element is the size:
On Fri, May 31, 2013 at 09:25:48AM +0200, Kostis Sagonas wrote:
} I am afraid this statement (relying on the structure being a tuple)
} breaks the opacity of the data structure. So does your call to
} element/2 below.
Indeed, I made that point. My answer was in the first sentence.
The rest of my post was unecessary editorializing.
} Since I've also stumbled across something analogous in the past,
} IMO the proper solution is to extend the API of these opaque data
} structures (these modules) by providing is_empty/1 functions for
Only if they are bifs will it help with my (unsolicited) example.
Sometimes it's just too compelling to resist taking advantage
of knowing how the opaque data structures work.
More information about the erlang-questions