fun replace(key: K?, value: V?): V? { var hash: Long var allocIndex: Long var segment: javax.swing.text.Segment<K?, V?> val oldValue: V if (segment(segmentIndex(keyHashCode(key).also { hash = it })).also { segment = it } .find(this, hash, key).also { allocIndex = it } > 0) { oldValue = segment.readValue(allocIndex) segment.writeValue(allocIndex, value) return oldValue } return null }
Replaces the entry for the specified key only if it is currently mapped to some value .