org.dthume.data.interval-treeset.selection

Interval treeset subset selection.

->

macro

(-> t lens & body)

Analogue of clojure.core/-> for use with selections.

Takes a selected region t, a lens (one of prefix, selected or suffix) and a body of expressions, and threads the component part value identified by lens through body with clojure.core/->. The result is convered to an interval treeset as per edit, and used as the new component part value.

->>

macro

(->> t lens & body)

Analogue of clojure.core/->> for use with selections.

Takes a selected region t, a lens (one of prefix, selected or suffix) and a body of expressions, and threads the component part value identified by lens through body with clojure.core/->>. The result is convered to an interval treeset as per edit, and used as the new component part value.

as->

macro

(as-> t lens n & body)

Analogue of clojure.core/as-> for use with selections.

Takes a selected region t, a lens (one of prefix, selected or suffix) and a body of expressions, and threads the component part value identified by lens through body with clojure.core/as->. The result is convered to an interval treeset as per edit, and used as the new component part value.

contractl

(contractl t n)

Contract the covered region to the left by n items.

contractl-by

(contractl-by t pred n)

Contract the covered region to the left until pred has returned logical true n times.

contractl-while

(contractl-while t pred)

Contract the covered region to the left while pred returns logical true.

contractr

(contractr t n)

Contract the covered region to the right by n items.

contractr-by

(contractr-by t pred n)

Contract the covered region to the right until pred has returned logical true n times.

contractr-while

(contractr-while t pred)

Contract the covered region to the right while pred returns logical true.

edit

(edit t lens f & args)

Edit a component part of t using lens (one of prefix, selected or suffix). f will be called with the value of the component part as the first argument, followed by any remaining args. The result will be converted to an interval treeset as described below, which will be used as the new value of the component part, and an updated selection region will be returned.

The result of f can be either nil, an interval treeset, or any sequential type:

  • nil will result in an empty interval treeset as the component part value.
  • An interval treeset will be used as is as the component part value.
  • Any other sequential type will be poured into an empty interval treeset (created from the original) which will be used as the component part value.

expandl

(expandl t n)

Expand the covered region to the left by n items.

expandl-by

(expandl-by t pred n)

Expand the covered region to the left until pred has returned logical true n times.

expandl-while

(expandl-while t pred)

Expand the covered region to the left while pred returns logical true.

expandr

(expandr t n)

Expand the covered region n items to the right.

expandr-by

(expandr-by t pred n)

Expand the covered region to the right until pred has evaluated to logical true n times.

expandr-while

(expandr-while t pred)

Expand the covered region to the right while pred evaluates to logical true

overlapping-subset

(overlapping-subset ts ival)

Search this for all values which overlap ival.

prefix

(prefix t)(prefix t v)

Lensing function for the prefix component part of a region. Return only the prefix part of this region in the one arg case, set the prefix part in the two arg case.

selected

(selected t)(selected t v)

Lensing function for the selected component part of a region. Return only the selected part of this region in the one arg case, set the selected part in the two arg case.

selection

(selection pre sel suff)

Create a selection from 3 trees: prefix selected and suffix.

slide-left

(slide-left t n)

Slide the covered region left by n items.

slide-left-by

(slide-left-by t pred n)

Slide the covered region left unti pred has returned logical true n times.

slide-left-while

(slide-left-while t pred)

Slide the covered region left while pred returns logical true.

slide-right

(slide-right t n)

Slide the covered region right by n items

slide-right-by

(slide-right-by t pred n)

Slide the covered region right until pred has returned logical true n times.

slide-right-while

(slide-right-while t pred)

Slide the covered region right while pred returns logical true.

suffix

(suffix t)(suffix t v)

Lensing function for the suffix component part of a region. Return only the suffix part of this region in the one arg case, set the suffix part in the two arg case.

transform

(transform t lens f & args)

Like edit, but passes the component value as the last argument to f rather than the first.

unselect

(unselect t)

Combine prefix, region and suffix back together to form an interval treeset.