datastructures.scm 16 KB

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