[ Non-logical Variables, Arrays, Bags, Shelves and Stores | Reference Manual | Alphabetic Index ]

store_count(+StoreHandle, -Count)

Retrieve the number of entries in a store object
StoreHandle
A store handle or store name
Count
Variable or integer

Description

This returns the count of the number of entries in a store object. For an empty store, 0 (zero) is returned.

Note: If StoreHandle is not a handle, then it must be an atom or a compound term, and the store is identified by this term's toplevel functor together with the context module.

Modes and Determinism

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Exceptions

(4) instantiation fault
StoreHandle is uninstantiated
(5) type error
StoreHandle is neither atom nor compound term nor store handle
(45) named object does not exist
StoreHandle is not the name of a store

Examples


    ?- store_create(Handle),
       store_count(Handle, N1),
       store_set(Handle, tom, 12345),
       store_count(Handle, N2),
       store_set(Handle, dick, 42376),
       store_count(Handle, N3),
       store_set(Handle, harry, 84223),
       store_count(Handle, N4),
       store_delete(Handle, dick),
       store_count(Handle, N5),
       store_erase(Handle),
       store_count(Handle, N6).

    Handle = $&(store,"17h3")
    N1 = 0
    N2 = 1
    N3 = 2
    N4 = 3
    N5 = 2
    N6 = 0
    Yes (0.00s cpu)
    

See Also

store / 1, store_create / 1, store_contains / 2, store_delete / 2, store_erase / 1, store_get / 3, store_inc / 2, store_insert / 3, store_remove / 3, store_test_and_set / 4, store_update / 4