Documentation ¶
Overview ¶
Package id provides zettel specific types, constants, and functions about zettel identifier.
Index ¶
- Constants
- Variables
- func ParseUint(s string) (uint64, error)
- func ParseUintN(s string) (uint64, error)
- type Digraph
- func (dg Digraph) AddEdge(fromZid, toZid Zid) Digraph
- func (dg Digraph) AddEgdes(edges EdgeSlice) Digraph
- func (dg Digraph) AddVertex(zid Zid) Digraph
- func (dg Digraph) Clone() Digraph
- func (dg Digraph) Edges() (es EdgeSlice)
- func (dg Digraph) Equal(other Digraph) bool
- func (dg Digraph) HasVertex(zid Zid) bool
- func (dg Digraph) IsDAG() (Zid, bool)
- func (dg Digraph) Originators() *Set
- func (dg Digraph) ReachableVertices(zid Zid) (tc *Set)
- func (dg Digraph) RemoveVertex(zid Zid)
- func (dg Digraph) Reverse() (revDg Digraph)
- func (dg Digraph) SortReverse() (sl Slice)
- func (dg Digraph) Terminators() (terms *Set)
- func (dg Digraph) TransitiveClosure(zid Zid) (tc Digraph)
- func (dg Digraph) Vertices() *Set
- type Edge
- type EdgeSlice
- type Set
- func (s *Set) Add(zid Zid) *Set
- func (s *Set) AddSlice(sl Slice) *Set
- func (s *Set) Clone() *Set
- func (s *Set) Contains(zid Zid) bool
- func (s *Set) ContainsOrNil(zid Zid) bool
- func (s *Set) Diff(other *Set) (newS, remS *Set)
- func (s *Set) Equal(other *Set) bool
- func (s *Set) ForEach(fn func(zid Zid))
- func (s *Set) ISubstract(other *Set)
- func (s *Set) IUnion(other *Set) *Set
- func (s *Set) IntersectOrSet(other *Set) *Set
- func (s *Set) IsEmpty() bool
- func (s *Set) Length() int
- func (s *Set) MetaString() string
- func (s *Set) Optimize()
- func (s *Set) Pop() (Zid, bool)
- func (s *Set) Remove(zid Zid) *Set
- func (s *Set) SafeSorted() Slice
- func (s *Set) String() string
- type Slice
- type Zid
- type ZidN
Constants ¶
const (
Invalid = Zid(0) // Invalid is a Zid that will never be valid
)
Some important ZettelIDs.
const (
InvalidN = ZidN(0) // Invalid is a Zid that will never be valid
)
Some important ZettelIDs.
const TimestampLayout = "20060102150405"
TimestampLayout to transform a date into a Zid and into other internal dates.
Variables ¶
var ( ConfigurationZid = MustParse(api.ZidConfiguration) BaseTemplateZid = MustParse(api.ZidBaseTemplate) LoginTemplateZid = MustParse(api.ZidLoginTemplate) ListTemplateZid = MustParse(api.ZidListTemplate) ZettelTemplateZid = MustParse(api.ZidZettelTemplate) InfoTemplateZid = MustParse(api.ZidInfoTemplate) FormTemplateZid = MustParse(api.ZidFormTemplate) RenameTemplateZid = MustParse(api.ZidRenameTemplate) DeleteTemplateZid = MustParse(api.ZidDeleteTemplate) ErrorTemplateZid = MustParse(api.ZidErrorTemplate) StartSxnZid = MustParse(api.ZidSxnStart) BaseSxnZid = MustParse(api.ZidSxnBase) PreludeSxnZid = MustParse(api.ZidSxnPrelude) EmojiZid = MustParse(api.ZidEmoji) TOCNewTemplateZid = MustParse(api.ZidTOCNewTemplate) DefaultHomeZid = MustParse(api.ZidDefaultHome) )
ZettelIDs that are used as Zid more than once.
Note: if you change some values, ensure that you also change them in the Constant box. They are mentioned there literally, because these constants are not available there.
Functions ¶
func ParseUint ¶
ParseUint interprets a string as a possible zettel identifier and returns its integer value.
func ParseUintN ¶ added in v0.18.0
ParseUintN interprets a string as a possible zettel identifier and returns its integer value.
Types ¶
type Digraph ¶ added in v0.14.0
Digraph relates zettel identifier in a directional way.
func (Digraph) AddEdge ¶ added in v0.14.0
AddEdge adds a connection from `zid1` to `zid2`. Both vertices must be added before. Otherwise the function may panic.
func (Digraph) AddEgdes ¶ added in v0.14.0
AddEgdes adds all given `Edge`s to the digraph.
In contrast to `AddEdge` the vertices must not exist before.
func (Digraph) Edges ¶ added in v0.14.0
Edges returns an unsorted slice of the edges of the digraph.
func (Digraph) Equal ¶ added in v0.14.0
Equal returns true if both digraphs have the same vertices and edges.
func (Digraph) HasVertex ¶ added in v0.14.0
HasVertex returns true, if `zid` is a vertex of the digraph.
func (Digraph) IsDAG ¶ added in v0.14.0
IsDAG returns a vertex and false, if the graph has a cycle containing the vertex.
func (Digraph) Originators ¶ added in v0.14.0
Originators will return the set of all vertices that are not referenced a the to-part of an edge.
func (Digraph) ReachableVertices ¶ added in v0.14.0
ReachableVertices calculates the set of all vertices that are reachable from the given `zid`.
func (Digraph) RemoveVertex ¶ added in v0.15.0
RemoveVertex removes a vertex and all its edges from the digraph.
func (Digraph) SortReverse ¶ added in v0.14.0
SortReverse returns a deterministic, topological, reverse sort of the digraph.
Works only if digraph is a DAG. Otherwise the algorithm will not terminate or returns an arbitrary value.
func (Digraph) Terminators ¶ added in v0.14.0
Terminators returns the set of all vertices that does not reference other vertices.
func (Digraph) TransitiveClosure ¶ added in v0.14.0
TransitiveClosure calculates the sub-graph that is reachable from `zid`.
type EdgeSlice ¶ added in v0.14.0
type EdgeSlice []Edge
EdgeSlice is a slice of Edges
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a set of zettel identifier
func NewSetCap ¶
NewSetCap returns a new set of identifier with the given capacity and initial values.
func (*Set) Contains ¶
Contains return true if the set is non-nil and the set contains the given Zettel identifier.
func (*Set) ContainsOrNil ¶ added in v0.14.0
ContainsOrNil return true if the set is nil or if the set contains the given Zettel identifier.
func (*Set) Diff ¶ added in v0.18.0
Diff returns the difference sets between the two sets: the first difference set is the set of elements that are in other, but not in s; the second difference set is the set of element that are in s but not in other.
in other words: the first result is the set of elements from other that must be added to s; the second result is the set of elements that must be removed from s, so that s would have the same elemest as other.
func (*Set) ForEach ¶ added in v0.18.0
ForEach calls the given function for each element of the set.
Every element is bigger than the previous one.
func (*Set) ISubstract ¶ added in v0.18.0
ISubstract removes all zettel identifier from 's' that are in the set 'other'.
func (*Set) IntersectOrSet ¶
IntersectOrSet removes all zettel identifier that are not in the other set. Both sets can be modified by this method. One of them is the set returned. It contains the intersection of both, if s is not nil.
If s == nil, then the other set is always returned.
func (*Set) MetaString ¶ added in v0.18.0
MetaString returns a string representation of the set to be stored as metadata.
func (*Set) Optimize ¶ added in v0.18.0
func (s *Set) Optimize()
Optimize the amount of memory to store the set.
func (*Set) SafeSorted ¶ added in v0.18.0
SafeSorted returns the set as a new sorted slice of zettel identifier.
type Slice ¶
type Slice []Zid
Slice is a sequence of zettel identifier. A special case is a sorted slice.
func (Slice) Equal ¶
Equal reports whether zs and other are the same length and contain the samle zettel identifier. A nil argument is equivalent to an empty slice.
func (Slice) MetaString ¶ added in v0.18.0
MetaString returns the slice as a string to be store in metadata.
type Zid ¶
type Zid uint64
Zid is the internal identifier of a zettel. Typically, it is a time stamp of the form "YYYYMMDDHHmmSS" converted to an unsigned integer. A zettelstore implementation should try to set the last two digits to zero, e.g. the seconds should be zero,
func MustParse ¶
MustParse tries to interpret a string as a zettel identifier and returns its value or panics otherwise.
func (Zid) Bytes ¶
Bytes converts the zettel identification to a byte slice of 14 digits. Only defined for valid ids.
func (Zid) IsValid ¶
IsValid determines if zettel id is a valid one, e.g. consists of max. 14 digits.
type ZidN ¶ added in v0.18.0
type ZidN uint32
ZidN is the internal identifier of a zettel. It is a number in the range 1..36^4-1 (1..1679615), as it is externally represented by four alphanumeric characters.
func MustParseN ¶ added in v0.18.0
MustParseN tries to interpret a string as a zettel identifier and returns its value or panics otherwise.
func ParseN ¶ added in v0.18.0
ParseN interprets a string as a zettel identification and returns its value.
func (ZidN) Bytes ¶ added in v0.18.0
Bytes converts the zettel identification to a byte slice of 14 digits. Only defined for valid ids.
func (ZidN) IsValid ¶ added in v0.18.0
IsValid determines if zettel id is a valid one, e.g. consists of max. 14 digits.