Table of Contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class User(@JsonProperty("userName") val name: String) | |
| val userObj = User("John") | |
| JsoniterKotlinSupport.enable() | |
| JsoniterAnnotationSupport.enable() | |
| val jsonUserString = JsonStream.serialize(userObj) | |
| // jsonUserString will contain: {"userName":"John"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.* | |
| /** | |
| * Created by yangwei-ms on 2017/7/14. | |
| */ | |
| class SkipList<T>(private val comparator: Comparator<T>) { | |
| private var curHeight: Int = 1 | |
| private val head: Node<T> = Node(null, MAX_HEIGHT) | |
| private val rnd: Random = Random(System.currentTimeMillis()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //First, define a custom bundle class as like as below | |
| import Foundation | |
| //A key used for exchanging associated object | |
| var _BUNDLE_KEY = 0 | |
| class BundleEx : Bundle { | |
| override func localizedString(forKey key: String, value: String?, table tableName: String?) -> String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun <T> Flow<T>.throttle(waitMillis: Int) = flow { | |
| coroutineScope { | |
| val context = coroutineContext | |
| var nextMillis = 0L | |
| var delayPost: Deferred<Unit>? = null | |
| collect { | |
| val current = SystemClock.uptimeMillis() | |
| if (nextMillis < current) { | |
| nextMillis = current + waitMillis |
OlderNewer