Last active
October 3, 2017 19:22
-
-
Save logrusorgru/b44b00f5aea2dac02bc1bc18c7f4d946 to your computer and use it in GitHub Desktop.
skyobject Refs API preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Len(pack Pack) (ln int, err error) | |
// presence check | |
HasHash(pack Pack, hash cipher.SHA256) (ok bool, err error) | |
// short hand for HasHash + pack.Get(hash) + encoder.DeserializeRaw | |
ValueByHash(pack Pack, hash cipher.SHA256, obj interface{}) (err error) | |
// the IndexByHash is useful only if the Refs contains only unique | |
// elements | |
IndexByHash(pack Pack, hash cipher.SHA256) (i int, err error) | |
IndicesByHash(pack Pack, hash cipher.SHA256) (is []int, err error) | |
ValueByHashWithIndex(pack Pack, hash cipher.SHA256, obj interface{}) (i int, err error) | |
HashByIndex(pack Pack, i int) (hash cipher.SHA256, err error) | |
ValueByIndex(pack Pack, i int, obj interface{}) (hash cipher.SHA256, err error) | |
// can set to cipher.SHA256{}, e.g. can make some hash blank | |
// wihtout removing | |
SetHashByIndex(pack Pack, i int, hash cipher.SHA256) (err error) | |
SetValueByIndex(pack Pack, i int, obj interface{}) (err error) | |
// remove elements reducing length of the Refs | |
DeleteByIndex(pack Pack, i int) (err error) | |
DeleteByHash(pack Pack, hash cipher.SHA256) (err error) // delete all | |
DeleteSliceByIndices(pack Pack, from, to int) (err error) | |
// get part of the Refs (creates new Refs) | |
Slice(pack Pack, i, j int) (slice *Refs, err error) | |
// iterate, allows modificatios by Set* and Delete* methods, but every modification, | |
// that changes length of the Refs, requires finding current element for next loop, | |
// for many (batch) modifications take a look at AscendModify, DecsendModify, etc methods | |
Ascend(pack Pack, ascendFunc func(i int, hash cipher.SHA256) (err error)) (err error) | |
Descend(pack Pack, descendFunc func(i int, hash cipher.SHA256) (err error)) (err error) | |
AscendFrom(pack Pack, from int, ascendFunc func(i int, hash cipher.SHA256) (err error)) (err error) | |
DescendFrom(pack Pack, from int, descendFunc func(i int, hash cipher.SHA256) (err error)) (err error) | |
// iterate changins/removing elements, this methods are better for batch operations | |
AscendModify(pack Pack, ascendFunc func(i int, hash cipher.SHA256) (newHash cipher.SHA256, del bool, err error)) (err error) | |
DescendModify(pack Pack, descendFunc func(i int, hash cipher.SHA256) (newHash cipher.SHA256, del bool, err error)) (err error) | |
AscendModifyFrom(pack Pack, from int, ascendFunc func(i int, hash cipher.SHA256) (newHash cipher.SHA256, del bool, err error)) (err error) | |
DescendModifyFrom(pack Pack, from int, descendFunc func(i int, hash cipher.SHA256) (newHash cipher.SHA256, del bool, err error)) (err error) | |
// append | |
AppendValues(pack Pack, obj ...interface{}) (err error) | |
AppendRefs(pack Pack, refs *Refs) (err error) | |
AppendHashes(pack Pack, hash ...cipher.SHA256) (err error) | |
// make blank | |
Clear() (err error) | |
// service | |
Rebuild(pack Pack) (err error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about
SetHashByHash
(orReplaceByHash
) that replaces all elements with given hash with new given hash?