Documentation ¶
Overview ¶
Package id provides zettel specific types, constants, and functions about zettel identifier.
Index ¶
- Constants
- Variables
- func ParseUint(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) Clone() Set
- func (s Set) Contains(zid Zid) bool
- func (s Set) ContainsOrNil(zid Zid) bool
- func (s Set) Copy(other Set) Set
- func (s Set) CopySlice(sl Slice) Set
- func (s Set) Equal(other Set) bool
- func (s Set) IntersectOrSet(other Set) Set
- func (s Set) Remove(zid Zid) Set
- func (s Set) Sorted() Slice
- func (s Set) String() string
- func (s Set) Substract(other Set)
- type Slice
- type Zid
Constants ¶
const (
Invalid = Zid(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 ¶
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 map[Zid]struct{}
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) CopySlice ¶ added in v0.14.0
CopySlice adds all identifier of the given slice to the set.
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.
type Slice ¶
type Slice []Zid
Slice is a sequence of zettel identifier. A special case is a sorted slice.
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.