Package org.gnome.glib
Class Cache
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.glib.Cache
- All Implemented Interfaces:
Proxy
Deprecated.
A
GCache allows sharing of complex data structures, in order to
save system resources.
GCache uses keys and values. A GCache key describes the properties
of a particular resource. A GCache value is the actual resource.
GCache has been marked as deprecated, since this API is rarely
used and not very actively maintained.
-
Constructor Summary
ConstructorsConstructorDescriptionCache(MemorySegment address) Deprecated.Create a Cache proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Deprecated.Use aGHashTableinstead@Nullable MemorySegmentinsert(@Nullable MemorySegment key) Deprecated.Use aGHashTableinsteadvoidkeyForeach(@Nullable HFunc func) Deprecated.Use aGHashTableinsteadstatic Cachenew_(@Nullable CacheNewFunc valueNewFunc, @Nullable CacheDestroyFunc valueDestroyFunc, @Nullable CacheDupFunc keyDupFunc, @Nullable CacheDestroyFunc keyDestroyFunc, @Nullable HashFunc hashKeyFunc, @Nullable HashFunc hashValueFunc, @Nullable EqualFunc keyEqualFunc) Deprecated.Use aGHashTableinsteadvoidremove(@Nullable MemorySegment value) Deprecated.Use aGHashTableinsteadvoidvalueForeach(@Nullable HFunc func) Deprecated.The reason is that it passes pointers to internal data structures tofunc;use g_cache_key_foreach() insteadMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Cache
Deprecated.Create a Cache proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
-
Method Details
-
new_
@Deprecated public static Cache new_(@Nullable CacheNewFunc valueNewFunc, @Nullable CacheDestroyFunc valueDestroyFunc, @Nullable CacheDupFunc keyDupFunc, @Nullable CacheDestroyFunc keyDestroyFunc, @Nullable HashFunc hashKeyFunc, @Nullable HashFunc hashValueFunc, @Nullable EqualFunc keyEqualFunc) Deprecated.Use aGHashTableinsteadCreates a newGCache.- Parameters:
valueNewFunc- a function to create a new object given a key. This is called by g_cache_insert() if an object with the given key does not already existvalueDestroyFunc- a function to destroy an object. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0)keyDupFunc- a function to copy a key. It is called by g_cache_insert() if the key does not already exist in theGCachekeyDestroyFunc- a function to destroy a key. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0)hashKeyFunc- a function to create a hash value from a keyhashValueFunc- a function to create a hash value from a valuekeyEqualFunc- a function to compare two keys. It should returntrueif the two keys are equivalent- Returns:
- a new
GCache
-
destroy
Deprecated.Use aGHashTableinsteadFrees the memory allocated for theGCache.Note that it does not destroy the keys and values which were contained in the
GCache. -
insert
Deprecated.Use aGHashTableinsteadGets the value corresponding to the given key, creating it if necessary. It first checks if the value already exists in theGCache, by using thekeyEqualFuncfunction passed to g_cache_new(). If it does already exist it is returned, and its reference count is increased by one. If the value does not currently exist, if is created by calling thevalueNewFunc.The key is duplicated by callingkeyDupFuncand the duplicated key and value are inserted into theGCache.- Parameters:
key- a key describing aGCacheobject- Returns:
- a pointer to a
GCachevalue
-
keyForeach
Deprecated.Use aGHashTableinsteadCalls the given function for each of the keys in theGCache.NOTE
funcis passed three parameters, the value and key of a cache entry and theuserData.The order of value and key is different from the order in which g_hash_table_foreach() passes key-value pairs to its callback function !- Parameters:
func- the function to call with eachGCachekey
-
remove
Deprecated.Use aGHashTableinsteadDecreases the reference count of the given value. If it drops to 0 then the value and its corresponding key are destroyed, using thevalueDestroyFuncandkeyDestroyFuncpassed to g_cache_new().- Parameters:
value- the value to remove
-
valueForeach
Deprecated.The reason is that it passes pointers to internal data structures tofunc;use g_cache_key_foreach() insteadCalls the given function for each of the values in theGCache.- Parameters:
func- the function to call with eachGCachevalue
-
GHashTableinstead