如果您想实现新的数据结构,则需要使用deftype而不是defrecord,因为后者为结果类型硬连线了映射行为的某种实现。
至于clojure.core采集功能,大多数都是基于接口而不是协议。(然而,ClojureScript 确实使用协议。)发现哪些接口可能与新数据结构相关的最简单方法是检查已经存在的类似数据结构:
;; all superclasses and interfaces of the class of {}, that is,\n;; clojure.lang.PersistentArrayMap\n(ancestors (class {}))\n\n;; interfaces only\n(filter #(.isInterface %) (ancestors (class {})))\nRun Code Online (Sandbox Code Playgroud)\n\n既然您计划实现一个特里树,我猜您想实现一个映射或集合。如果是这样,data.avl实现了所有相关接口(以及 ClojureScript 版本中的所有相关协议) \xe2\x80\x93 你可以看看源代码。
\n