官术网_书友最值得收藏!

Discovering the concept of sequences

In terms of high-level functionalities, the Sequence and Collection data structures are nearly the same. They both allow iteration through their elements. There are also many powerful extension functions in the Kotlin standard library that provide declarative-style data-processing operations for each of them. However, the Sequence data structure behaves differently under the hood—it delays any operations on its elements until they are finally consumed. It instantiates the subsequent elements on the go while traversing through them. These characteristics of Sequence, called lazy evaluation, make this data structure quite similar to the Java concept,  Stream.  To understand all of this better, we are going to implement a simple data-processing scenario to analyze the efficiency and behavior of Sequence and contrast our findings with Collection-based implementation.

主站蜘蛛池模板: 云梦县| 绥江县| 綦江县| 涟源市| 花莲市| 肥乡县| 大田县| 渝北区| 武山县| 驻马店市| 页游| 启东市| 巨野县| 揭阳市| 怀集县| 巨野县| 新宁县| 怀化市| 镇康县| 江都市| 文昌市| 凤阳县| 凌海市| 武乡县| 桓仁| 雷州市| 临海市| 呼和浩特市| 涿鹿县| 梁平县| 阿拉善盟| 宜宾市| 如皋市| 隆德县| 登封市| 义乌市| 漯河市| 湟中县| 北安市| 石棉县| 杂多县|