D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
ObjectSpace
/
WeakMap
/
Filename :
cdesc-WeakMap.ri
back
Copy
U:RDoc::NormalClass[iI"WeakMap:ETI"ObjectSpace::WeakMap;TI"Object;To:RDoc::Markup::Document:@parts[o;;[ o:RDoc::Markup::Paragraph;[I"KAn ObjectSpace::WeakMap is a key-value map that holds weak references ;TI"Mto its keys and values, so they can be garbage-collected when there are ;TI"no more references left.;To:RDoc::Markup::BlankLine o; ;[I".Keys in the map are compared by identity.;T@o:RDoc::Markup::Verbatim;[I""m = ObjectSpace::WeakMap.new ;TI"key1 = "foo" ;TI"val1 = Object.new ;TI"m[key1] = val1 ;TI" ;TI"key2 = "bar" ;TI"val2 = Object.new ;TI"m[key2] = val2 ;TI" ;TI""m[key1] #=> #<Object:0x0...> ;TI""m[key2] #=> #<Object:0x0...> ;TI" ;TI"6val1 = nil # remove the other reference to value ;TI"GC.start ;TI" ;TI"m[key1] #=> nil ;TI"m.keys #=> ["bar"] ;TI" ;TI"4key2 = nil # remove the other reference to key ;TI"GC.start ;TI" ;TI"m[key2] #=> nil ;TI"m.keys #=> [] ;T:@format0o; ;[I"R(Note that GC.start is used here only for demonstrational purposes and might ;TI".not always lead to demonstrated results.);T@o; ;[I"OSee also ObjectSpace::WeakKeyMap map class, which compares keys by value, ;TI"0and holds weak references only to the keys.;T: @fileI"weakmap.c;T:0@omit_headings_from_table_of_contents_below0; 0;0[ [ [[I"Enumerable;To;;[ ; @8;0I"weakmap.c;T[[I" class;T[[:public[ [:protected[ [:private[ [I" instance;T[[;[[I"[];T@@[I"[]=;T@@[I"delete;T@@[I" each;T@@[I" each_key;T@@[I"each_pair;T@@[I"each_value;T@@[I" include?;T@@[I"inspect;T@@[I" key?;T@@[I" keys;T@@[I"length;T@@[I"member?;T@@[I" size;T@@[I"values;T@@[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ; 0;0[I"ext/objspace/objspace.c;TI"ObjectSpace;TcRDoc::NormalModule