Skip to content

Commit

Permalink
Some helper functions to make DupleNode easy 2 use
Browse files Browse the repository at this point in the history
  • Loading branch information
damienstamates committed Jul 31, 2019
1 parent 8024dfe commit b174dbb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ func (d *DupleNode) Unique() (duples []Duple) {
return duples
}

// Find will return a reference to a duple given that it is found
// in the slice of duples in the DupleNode.
func (d *DupleNode) Find(predicate string) *Duple {
for _, dple := range d.Duples {
if dple.Predicate == predicate {
return &dple
}
}

return nil
}

// AddDuples appends new duples given in the function.
// Then returns the reference to the DupleNode.
func (d *DupleNode) AddDuples(duple ...Duple) *DupleNode {
d.Duples = append(d.Duples, duple...)
return d
}

// Credit: The Go Authors @ "encoding/json"
// tagOptions is the string following a comma in a struct field's "quirk"
// tag, or the empty string. It does not include the leading comma.
Expand Down

0 comments on commit b174dbb

Please sign in to comment.