Class: Java::Util::HashMap
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Java::Util::HashMap
- Extended by:
- JavaObject
- Defined in:
- lib/javaobs.rb
Instance Method Summary collapse
- #_readJavaData(stream) ⇒ Object
- #_writeJavaData(stream) ⇒ Object
-
#initialize ⇒ HashMap
constructor
A new instance of HashMap.
Methods included from JavaObject
Constructor Details
#initialize ⇒ HashMap
Returns a new instance of HashMap.
138 139 140 141 142 |
# File 'lib/javaobs.rb', line 138 def initialize super(Hash) @loadFactor = 0.75 @threshold = 12 end |
Instance Method Details
#_readJavaData(stream) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/javaobs.rb', line 144 def _readJavaData(stream) # Read loadFactor and threshold. stream.defaultReadObject(self) stream.readBlockStart len = stream.readInt size = stream.readInt h = Hash.new size.times do k = stream.readObject v = stream.readObject h[k] = v end stream.readBlockEnd __setobj__(h) end |
#_writeJavaData(stream) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/javaobs.rb', line 161 def _writeJavaData(stream) obj = __getobj__; stream.defaultWriteObject(self) stream.writeBlockStart(8) l = 16 len = obj.length while l < len l << 1 end stream.writeInt(l) stream.writeInt(len) obj.each do |k, v| stream.writeObject(k) stream.writeObject(v) end stream.writeBlockEnd end |