Documentation
¶
Index ¶
Constants ¶
const ( // Signs that it is a book reference. BookRef refType = iota // Signs that it is a chapter reference. ChapterRef // Signs that the reference contains a single verse. SingleVerseRef // Signs that the reference contains a verse range. RangeVerseRef // Signs that the reference contains a list of verses. ListVerseRef )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct { // Version is a reference to the version which the book belongs to. Version *Version Number int Name string Chapters []Chapter }
Book docs here.
type Branch ¶
type Branch[K comparable, V any] struct { // contains filtered or unexported fields }
Branch gathers a matching key, an optional value (ending branches should always have a value; root branch should never have a value) and its subbranches.
func NewTree ¶
func NewTree[K comparable, V any]() *Branch[K, V]
NewTree returns a new tree with no branches.
func (*Branch[K, V]) Insert ¶
func (branch *Branch[K, V]) Insert(key []K, val *V)
Insert inserts a key in a branch, creating subbranches necessary to accomodate its path to given a value, which will be attached to the end of the branch.
func (*Branch[K, V]) Search ¶
func (branch *Branch[K, V]) Search(key []K) *V
Search searches for a key in a branch and its subbranches. If a unumbiguous value is found, it is returned; otherwise, yields nil. An unumbiguous value is only asserted with partial keys. A partial key doesn't contain all the values needed to match an entire key, but can match a value if there's only one subbranch in the branch that it reached. TODO: include a drawing illustrating this concept.
type Chapter ¶
type Chapter struct { // Book is a reference to the book which the chapter belongs to. Book *Book Number int Verses []Verse }
Chapter docs here.
func (*Chapter) VerseRange ¶
VerseRange docs here.
type Ref ¶
type Ref struct { // Type indicates how the reference should be interpreted. See RefType and // constants of this type. Type refType // BookName references the book name. Relevant to all types, for it must // always be present. BookName string // ChapterNum references the chapter number. Relevant for type ChapterRef, // SingleVerseRef, RangeVerseRef and ListVerseRef. ChapterNum int // VerseNum references the lower index when the type is RangeVerseRef, or // the verse number when the type is SingleVerseRef. VerseNum int // EndVerseNum references the higher index when the type is RangeVerseRef. EndVerseNum int // VerseNums references unrelated verse numbers when the type is // ListVerseRef. VerseNums []int }
Ref represents a generic reference of a verse, or a collection of verses, that can be indepently built and applied to versions.