API description correction
This commit is contained in:
parent
6819866c48
commit
01e3b2fb38
@ -12,7 +12,7 @@ import java.util.*
|
||||
* 2. Due to condition above, and due to sublying storage most of time being
|
||||
* mutable, it is expected you do defensive copies. Examples of when you should do
|
||||
* them are described on related interfaces.
|
||||
* 3. For storing stacks as [Map] keys, a stack with size of 1 is utilized (requiring [equals] and [hashCode] to return meaningful results).
|
||||
* 3. For storing stacks as [Map] keys, a stack with size of 1 is utilized (requiring [equals] and [hashCode] to return meaningful results, see [IStorageStack.key]).
|
||||
* 4. For equality (INCLUDING count), regular [equals] is utilized.
|
||||
*/
|
||||
interface IStorageStack {
|
||||
@ -54,6 +54,14 @@ interface IStorageStack {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (Supposedly shallow) Copies this object and sets it's count to 1 for use as map key.
|
||||
*
|
||||
* Equals to next code:
|
||||
* ```kotlin
|
||||
* this.copy().also { it.count = ImpreciseFraction.ONE }
|
||||
* ```
|
||||
*/
|
||||
fun <T : IStorageStack> T.key(): T {
|
||||
return copy().also { it.count = ImpreciseFraction.ONE } as T
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user