Remove predicate
Posted: 27 Jun 2016 20:44
Hello Thomas and fellow users,
the implementation of the remove predicate in mapMSupport does not use the custom key comparison and its runtime is in O(n) (where -as usual- n denotes the number of elements in the collection):
Therefor it could be replaced by
However it then still ignores the data part of the key/data-tuple, albeit the implementation of the contains predicate compares that part too:
Maybe the optimal solution would be, to introduce an additional custom data comparator, which defaults analogously to the custom key comparator to ::compare and use it in the remove and contains predicates.
Regards
Martin
the implementation of the remove predicate in mapMSupport does not use the custom key comparison and its runtime is in O(n) (where -as usual- n denotes the number of elements in the collection):
Code: Select all
remove(T) :-
if T = site:getAll_nd() then
tuple(Key, _Value) = T,
site:removeKey(Key)
end if.
Code: Select all
remove(tuple(Key, _Value)) :-
site:removeKey(Key).
Code: Select all
contains(tuple(Key, Value)) :-
Value = site:tryGet(Key).
Regards
Martin