datastructures.scm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015, 2016, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2016, 2017, 2019–2021 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;; Copyright © 2018 Meiyo Peng <meiyo.peng@gmail.com>
  5. ;;; Copyright © 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
  6. ;;; Copyright © 2020 Mark H Weaver <mhw@netris.org>
  7. ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
  8. ;;;
  9. ;;; This file is part of GNU Guix.
  10. ;;;
  11. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  12. ;;; under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation; either version 3 of the License, or (at
  14. ;;; your option) any later version.
  15. ;;;
  16. ;;; GNU Guix is distributed in the hope that it will be useful, but
  17. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  23. (define-module (gnu packages datastructures)
  24. #:use-module (gnu packages)
  25. #:use-module (gnu packages autotools)
  26. #:use-module (gnu packages boost)
  27. #:use-module (gnu packages build-tools) ;for meson-0.55
  28. #:use-module (gnu packages perl)
  29. #:use-module ((guix licenses) #:prefix license:)
  30. #:use-module (guix packages)
  31. #:use-module (guix download)
  32. #:use-module (guix git-download)
  33. #:use-module (guix build-system cmake)
  34. #:use-module (guix build-system gnu)
  35. #:use-module (guix build-system meson))
  36. (define-public gdsl
  37. (package
  38. (name "gdsl")
  39. (version "1.8")
  40. (source (origin
  41. (method git-fetch)
  42. (uri (git-reference
  43. (url "https://example.org") ;only hosted on Software Heritage
  44. (commit "6adb53be8b8f9f2e4bbfc92d357eedeefb4c7430")))
  45. (file-name (git-file-name name version))
  46. (sha256
  47. (base32
  48. "0a52g12d9sf9hhcyvwfd7xdazj2a9i9jh97cnlqf2ymvwnvjk1g0"))))
  49. (build-system gnu-build-system)
  50. (home-page "https://web.archive.org/web/20170502005430/http://home.gna.org/gdsl/")
  51. (synopsis "Generic data structures library")
  52. (description "The Generic Data Structures Library (GDSL) is a collection
  53. of routines for generic data structures manipulation. It is a re-entrant
  54. library fully written from scratch in pure ANSI C. It is designed to offer
  55. for C programmers common data structures with powerful algorithms, and hidden
  56. implementation. Available structures are lists, queues, stacks, hash tables,
  57. binary trees, binary search trees, red-black trees, 2D arrays, permutations
  58. and heaps.")
  59. (license license:gpl2+)))
  60. (define-public marisa
  61. (package
  62. (name "marisa")
  63. (version "0.2.6")
  64. (source
  65. (origin
  66. (method url-fetch)
  67. (uri (string-append "https://github.com/s-yata/marisa-trie/files/"
  68. "4832504/marisa-" version ".tar.gz"))
  69. (sha256
  70. (base32 "1pk6wmi28pa8srb4szybrwfn71jldb61c5vgxsiayxcyg1ya4qqh"))))
  71. (build-system gnu-build-system)
  72. (native-inputs
  73. `(("autoconf" ,autoconf)
  74. ("automake" ,automake)
  75. ("libtool" ,libtool)))
  76. (home-page "https://github.com/s-yata/marisa-trie")
  77. (synopsis "Trie data structure C++ library")
  78. (description "@acronym{MARISA, Matching Algorithm with Recursively
  79. Implemented StorAge} is a static and space-efficient trie data structure C++
  80. library.")
  81. ;; Dual-licensed, according to docs/readme.en.html (source files lack
  82. ;; copyright/license headers.)
  83. (license (list license:bsd-2 license:lgpl2.1+))))
  84. (define-public sparsehash
  85. (package
  86. (name "sparsehash")
  87. (version "2.0.4")
  88. (source (origin
  89. (method git-fetch)
  90. (uri (git-reference
  91. (url "https://github.com/sparsehash/sparsehash")
  92. (commit (string-append name "-" version))))
  93. (file-name (git-file-name name version))
  94. (sha256
  95. (base32
  96. "1pf1cjvcjdmb9cd6gcazz64x0cd2ndpwh6ql2hqpypjv725xwxy7"))))
  97. (build-system gnu-build-system)
  98. (synopsis "Memory-efficient hashtable implementations")
  99. (description
  100. "This library contains several hash-map implementations, similar in API
  101. to SGI's @code{hash_map} class, but with different performance
  102. characteristics. @code{sparse_hash_map} uses very little space overhead, 1-2
  103. bits per entry. @code{dense_hash_map} is very fast, particularly on lookup.
  104. @code{sparse_hash_set} and @code{dense_hash_set} are the set versions of these
  105. routines. All these implementation use a hashtable with internal quadratic
  106. probing. This method is space-efficient -- there is no pointer overhead --
  107. and time-efficient for good hash functions.")
  108. (home-page "https://github.com/sparsehash/sparsehash")
  109. (license license:bsd-3)))
  110. (define-public ssdeep
  111. (package
  112. (name "ssdeep")
  113. (version "2.14.1")
  114. (source
  115. (origin
  116. (method url-fetch)
  117. (uri (string-append "https://github.com/ssdeep-project/ssdeep/"
  118. "releases/download/release-" version "/"
  119. "ssdeep-" version ".tar.gz"))
  120. (sha256
  121. (base32 "04qkjc6kksxkv7xbnk32rwmf3a8czdv2vvrdzfs0kw06h73snbpz"))))
  122. (build-system gnu-build-system)
  123. (arguments
  124. `(#:configure-flags
  125. (list "--disable-static")))
  126. (home-page "https://ssdeep-project.github.io")
  127. (synopsis "Context-triggered piecewise hashing algorithm")
  128. (description "ssdeep computes and matches context triggered piecewise
  129. hashes (CTPH), also called fuzzy checksums. It can identify similar files
  130. that have sequences of identical bytes in the same order, even though bytes
  131. in between these sequences may be different in both content and length.")
  132. (license license:gpl2+)))
  133. (define-public liburcu
  134. (package
  135. (name "liburcu")
  136. (version "0.13.0")
  137. (source (origin
  138. (method url-fetch)
  139. (uri (string-append "https://www.lttng.org/files/urcu/"
  140. "userspace-rcu-" version ".tar.bz2"))
  141. (sha256
  142. (base32
  143. "085s437nig6bdiv9im4k4qwqbrbnc4qw9flqi16jlb493az0vcnb"))))
  144. (build-system gnu-build-system)
  145. (native-inputs
  146. `(("perl" ,perl))) ; for tests
  147. (home-page "https://liburcu.org/")
  148. (synopsis "User-space RCU data synchronisation library")
  149. (description "liburcu is a user-space @dfn{Read-Copy-Update} (RCU) data
  150. synchronisation library. It provides read-side access that scales linearly
  151. with the number of cores. liburcu-cds provides efficient data structures
  152. based on RCU and lock-free algorithms. These structures include hash tables,
  153. queues, stacks, and doubly-linked lists.")
  154. (license license:lgpl2.1+)))
  155. (define-public uthash
  156. (package
  157. (name "uthash")
  158. (version "2.1.0")
  159. (source
  160. (origin
  161. (method git-fetch)
  162. (uri (git-reference
  163. (url "https://github.com/troydhanson/uthash")
  164. (commit (string-append "v" version))))
  165. (file-name (git-file-name name version))
  166. (sha256
  167. (base32 "0k80bjbb6ss5wpmfmfji6xbyjm990hg9kcshwwnhdnh73vxkcd1m"))))
  168. (build-system gnu-build-system)
  169. (native-inputs
  170. `(("perl" ,perl)))
  171. (arguments
  172. `(#:make-flags
  173. (list "CC=gcc")
  174. #:phases
  175. (modify-phases %standard-phases
  176. (delete 'configure) ; nothing to configure
  177. (delete 'build) ; nothing to build
  178. (replace 'check
  179. (lambda* (#:key make-flags #:allow-other-keys)
  180. (with-directory-excursion "tests"
  181. (apply invoke "make" make-flags))))
  182. (replace 'install
  183. ;; There is no top-level Makefile to do this for us.
  184. (lambda* (#:key outputs #:allow-other-keys)
  185. (let* ((out (assoc-ref outputs "out"))
  186. (doc (string-append out "/share/doc/" ,name "-" ,version))
  187. (include (string-append out "/include")))
  188. ;; Don't install HTML files: they're just the below .txt files
  189. ;; dolled up, can be stale, and regeneration requires asciidoc.
  190. (for-each (λ (file) (install-file file doc))
  191. (find-files "doc" "\\.txt$"))
  192. (for-each (λ (file) (install-file file include))
  193. (find-files "src" "\\.h$"))
  194. #t))))))
  195. (home-page "https://troydhanson.github.io/uthash/")
  196. (synopsis
  197. "Hash tables, lists, and other data structures implemented as C macros")
  198. (description
  199. "uthash implements a hash table and a few other basic data structures
  200. as C preprocessor macros. It aims to be minimalistic and efficient: it's
  201. around 1,000 lines of code which, being macros, inline automatically.
  202. Unlike function calls with fixed prototypes, macros operate on untyped
  203. arguments. Thus, they are able to work with any type of structure and key.
  204. Any C structure can be stored in a hash table by adding @code{UT_hash_handle}
  205. to the structure and choosing one or more fields to act as the key.")
  206. (license license:bsd-2)))
  207. (define-public sdsl-lite
  208. (package
  209. (name "sdsl-lite")
  210. (version "2.1.1")
  211. (source (origin
  212. (method url-fetch)
  213. (uri (string-append "https://github.com/simongog/sdsl-lite/"
  214. "releases/download/v" version "/"
  215. "sdsl-lite-" version
  216. ".tar.gz.offline.install.gz"))
  217. (sha256
  218. (base32
  219. "1v86ivv3mmdy802i9xkjpxb4cggj3s27wb19ja4sw1klnivjj69g"))
  220. (modules '((guix build utils)))
  221. (snippet
  222. '(begin
  223. (delete-file-recursively "external") #t))
  224. (patches
  225. (list (origin
  226. (method url-fetch)
  227. (uri "https://salsa.debian.org/science-team/libsdsl/raw/debian/2.1.1+dfsg-2/debian/patches/0001-Patch-cmake-files.patch")
  228. (file-name "sdsl-lite-dont-use-bundled-libraries.patch")
  229. (sha256
  230. (base32
  231. "0m542xpys54bni29zibgrfpgpd0zgyny4h131virxsanixsbz52z")))))))
  232. (build-system cmake-build-system)
  233. (arguments
  234. `(#:phases
  235. (modify-phases %standard-phases
  236. (add-after 'install 'install-static-library
  237. (lambda* (#:key outputs #:allow-other-keys)
  238. (let ((out (assoc-ref outputs "out")))
  239. (copy-file "lib/libsdsl_static.a"
  240. (string-append out "/lib/libsdsl.a")))
  241. #t))
  242. (add-after 'install 'install-pkgconfig-file
  243. (lambda* (#:key outputs #:allow-other-keys)
  244. (let* ((out (assoc-ref outputs "out"))
  245. (lib (string-append out "/lib")))
  246. (mkdir-p (string-append lib "/pkgconfig"))
  247. (with-output-to-file (string-append lib "/pkgconfig/sdsl-lite.pc")
  248. (lambda _
  249. (format #t "prefix=~a~@
  250. exec_prefix=${prefix}~@
  251. libdir=${exec_prefix}/lib~@
  252. includedir=${prefix}/include~@
  253. ~@
  254. ~@
  255. Name: sdsl~@
  256. Version: ~a~@
  257. Description: SDSL: Succinct Data Structure Library~@
  258. Libs: -L${libdir} -lsdsl -ldivsufsort -ldivsufsort64~@
  259. Cflags: -I${includedir}~%"
  260. out ,version)))
  261. #t))))))
  262. (native-inputs
  263. `(("libdivsufsort" ,libdivsufsort)))
  264. (home-page "https://github.com/simongog/sdsl-lite")
  265. (synopsis "Succinct data structure library")
  266. (description "The Succinct Data Structure Library (SDSL) is a powerful and
  267. flexible C++11 library implementing succinct data structures. In total, the
  268. library contains the highlights of 40 research publications. Succinct data
  269. structures can represent an object (such as a bitvector or a tree) in space
  270. close to the information-theoretic lower bound of the object while supporting
  271. operations of the original object efficiently. The theoretical time
  272. complexity of an operation performed on the classical data structure and the
  273. equivalent succinct data structure are (most of the time) identical.")
  274. (license license:gpl3+)))
  275. (define-public tllist
  276. (package
  277. (name "tllist")
  278. (version "1.0.5")
  279. (home-page "https://codeberg.org/dnkl/tllist")
  280. (source (origin
  281. (method git-fetch)
  282. (uri (git-reference (url home-page) (commit version)))
  283. (file-name (git-file-name name version))
  284. (sha256
  285. (base32
  286. "061mkg6hc9x89zya3bw18ymxlzd8fbhjipxpva8x01lh2vp1d4f0"))))
  287. (build-system meson-build-system)
  288. (synopsis "Typed link list for C")
  289. (description
  290. "@code{tllist} is a @dfn{typed linked list} C header file only library
  291. implemented using pre-processor macros. It supports primitive data types as
  292. well as aggregated ones such as structs, enums and unions.")
  293. (license license:expat)))
  294. (define-public libdivsufsort
  295. (package
  296. (name "libdivsufsort")
  297. (version "2.0.1")
  298. (source (origin
  299. (method git-fetch)
  300. (uri (git-reference
  301. (url "https://github.com/y-256/libdivsufsort")
  302. (commit version)))
  303. (file-name (git-file-name name version))
  304. (sha256
  305. (base32
  306. "0fgdz9fzihlvjjrxy01md1bv9vh12rkgkwbm90b1hj5xpbaqp7z2"))))
  307. (build-system cmake-build-system)
  308. (arguments
  309. '(#:tests? #f ; there are no tests
  310. #:configure-flags
  311. ;; Needed for rapmap and sailfish.
  312. '("-DBUILD_DIVSUFSORT64=ON")))
  313. (home-page "https://github.com/y-256/libdivsufsort")
  314. (synopsis "Lightweight suffix-sorting library")
  315. (description "libdivsufsort is a software library that implements a
  316. lightweight suffix array construction algorithm. This library provides a
  317. simple and an efficient C API to construct a suffix array and a
  318. Burrows-Wheeler transformed string from a given string over a constant-size
  319. alphabet. The algorithm runs in O(n log n) worst-case time using only 5n+O(1)
  320. bytes of memory space, where n is the length of the string.")
  321. (license license:expat)))
  322. (define-public robin-map
  323. (package
  324. (name "robin-map")
  325. (version "0.6.3")
  326. (source (origin
  327. (method git-fetch)
  328. (uri (git-reference
  329. (url "https://github.com/Tessil/robin-map")
  330. (commit (string-append "v" version))))
  331. (file-name (git-file-name name version))
  332. (sha256
  333. (base32
  334. "1li70vwsksva9c4yly90hjafgqfixi1g6d52qq9p6r60vqc4pkjj"))))
  335. (build-system cmake-build-system)
  336. (native-inputs
  337. `(("boost" ,boost))) ; needed for tests
  338. (arguments
  339. `(#:phases
  340. (modify-phases %standard-phases
  341. (replace 'check
  342. (lambda _
  343. (mkdir "tests")
  344. (with-directory-excursion "tests"
  345. (invoke "cmake" "../../source/tests")
  346. (invoke "cmake" "--build" ".")
  347. (invoke "./tsl_robin_map_tests")))))))
  348. (home-page "https://github.com/Tessil/robin-map")
  349. (synopsis "C++ implementation of a fast hash map and hash set")
  350. (description "The robin-map library is a C++ implementation of a fast hash
  351. map and hash set using open-addressing and linear robin hood hashing with
  352. backward shift deletion to resolve collisions.
  353. Four classes are provided: tsl::robin_map, tsl::robin_set, tsl::robin_pg_map
  354. and tsl::robin_pg_set. The first two are faster and use a power of two growth
  355. policy, the last two use a prime growth policy instead and are able to cope
  356. better with a poor hash function.")
  357. (license license:expat)))