• Stars
    star
    7
  • Rank 2,222,890 (Top 46 %)
  • Language
    Clojure
  • License
    Eclipse Public Li...
  • Created about 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Clojure hierarchical set.

hier-set

Library providing a "hierarchical set" data structure. The provided data structure is set of elements with a defined hierarchical relationship. An element is considered to be in the set either if it is provided as a primary set member or if it is a descendant of any such element. Lookup in the set not only determines set membership, but also finds all primary set members which are ancestors of the lookup element.

The hierarchical relationship is defined by the element sort-order and a separate containment predicate, with the following constraints:

  • elements must sort prior to any descendants; and
  • elements must contain all elements which sort between themselves and any descendant.

This is sufficient to represent simple hierarchical systems where the hierarchy is implicit in the entities involved, such as the Java package system, hierarchical filesystems, or IP networks. It is inappropriate for modeling complex, ad hoc hierarchies, such as the relationships between classes with multiple inheritance.

Usage

Add hier-set to the :dependencies list in your Leiningen project.clj:

[hier-set "1.1.2"]

Primary usage is then through the hier-set and hier-set-by constructor functions in the hier-set.core namespace. In addition to set lookup as described above, the hier-set.core/ancestors and hier-set.core/descendants functions also provide access to lazy sequences of the ancestors and descendants respectively of a provided key.

Example

A trivial example:

(ns example.hier-set
  (:require [hier-set.core :as hs])
  (:use [hier-set.core :only [hier-set]])

(def with-starts? #(.startsWith %2 %1))

(def hs (hier-set with-starts? "ack" "foo" "foo.bar" "quux")

(get hs "bar")              ;;=> nil
(get hs "foo")              ;;=> ("foo")
(get hs "foo.bar.baz")      ;;=> ("foo.bar" "foo")
(hs/ancestors hs "bar")     ;;=> ()
(hs/ancestors hs "foo.baz") ;;=> ("foo")
(hs/descendants hs "foo")   ;;=> ("foo" "foo.bar")

License

Copyright © 2012, 2014 Marshall Bockrath-Vandegrift.

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

More Repositories

1

godot-visibility-demo

Godot 2D tile lighting and visibility demo
GDScript
17
star
2

method-fn

A Clojure library augmenting Java methods as functions.
Clojure
8
star
3

zmforth

ZmForth! is an ANS Forth implementation for the Z-machine
Forth
5
star
4

shady

A collection of inter-operators for JVM Clojure
Clojure
5
star
5

rcfiles

Personal configuration etc files
Emacs Lisp
5
star
6

lein-ragel

Leiningen plugin to compile Ragel source files.
Clojure
4
star
7

lein-hadoop-cluster

A Leiningen plugin for running tasks against a live Hadoop cluster
Clojure
4
star
8

byteable

Clojure protocol-based serialization interface for Hadoop.
Clojure
2
star
9

trending-terms

Decade-wise trending terms in the Google Books n-grams corpus
Clojure
2
star
10

parenskit

Clojure integration library for the LensKit framework.
Clojure
2
star
11

nockor

Knock knock. Who's there? Orange!
1
star
12

euler-rust

Project Euler problem solutions, in Rust
Rust
1
star
13

esfj

A Clojure library for defining JSR-330 Provider classes.
Clojure
1
star
14

rogan

A (nightly-)Rust client for the Starfighter Stockfighter API
Rust
1
star
15

billninja

As simple as possible bill-sharing service that runs on Google App Engine
1
star
16

clj-eval-assignment

Clojure port of `eval-assignment` template
Java
1
star
17

letterpress

Locally-configurable Clojure data printers.
Java
1
star
18

puzzles

Code for solving various wooden-block puzzles
Python
1
star
19

playground.clj

Collection of utility functions and experimental code
Clojure
1
star
20

openssl-2xdrop-rust

Minimal reproduction case for rust-openssl double-drop bug
Rust
1
star
21

clj-uu-assignment

Clojure port of `uu-assignment` template.
Java
1
star