Functional Programming With Java 简明教程
Persistent Data Structure
如果数据结构有能力将之前更新作为一个单独版本来保存,并且可以访问和更新每个版本,则称它为持续的。它使数据结构变得不可变并且是线程安全的。例如,Java 中的 String 类对象是不可变的。每当我们对字符串进行任何更改时,JVM 都会创建一个新的字符串对象,为其赋予新值并将较旧的值保留为旧的字符串对象。
A data structure is said to be persistent if it is capable to maintaining its previous updates as separate versions and each version can be accessed and updated accordingly. It makes the data structure immutable and thread safe. For example, String class object in Java is immutable. Whenever we make any change to string, JVM creates another string object, assigned it the new value and preserve the older value as old string object.
持久数据结构也被称为函数式数据结构。考虑以下情况——
A persistent data structure is also called a functional data structure. Consider the following case −