R/clear.R

# ---------------------------------------------------------------------
# clear.R
# METHOD: clear
#   clears, rm all key-value pairs from a hash without destroying the 
#   hash
# 
#  TODO:
#   - for large hashes it might be more efficient to re-initialize the 
#     slot than rm the keys on the hash.
#
# ---------------------------------------------------------------------	

setGeneric( "clear", function(x) standardGeneric("clear") )

setMethod( "clear" , "hash" ,
   function(x) rm( list=keys(x), envir=x@.Data )
)

Try the hash package in your browser

Any scripts or data that you put into this service are public.

hash documentation built on Aug. 20, 2023, 1:08 a.m.