Ok, it may look like it but I don't want to track the cursor in the datatype itself most especially for reasons being that even one of the 'sideways walk' functions in the library needs to keep a copy of the coordinate of the previous node iterated past in order to identify when the direction (left or right) changes, for specific (common) cases. The Bast is the data structure and contains all the data. Cursor is just a convenience way of storing the coordinate in the tree, the row of the coordinate and an easy way to return error values. So the 'cursor' has to be usable in external code, and external also to the data it points at, because there could be multiple trees being operated on within one application using this library.
On Thursday, 19 April 2018 08:31:01 UTC+3, Jan Mercl wrote: > > On Thu, Apr 19, 2018 at 6:57 AM Louki Sumirniy <louki.sumir...@gmail.com > <javascript:>> wrote: > >> >> func (b *Bast) Parent(c Cursor) Cursor { >> if c.Index == 0 { >> c.Err = errors.New("No parent from the root") >> return c >> } >> c.Row-- >> c.Index = c.Index>>1 - (c.Index+1)%2 >> c.Err = nil >> return c >> } >> > > This method looks like it should be defined be on *Cursor receiver, not > *Bast. > > -- > > -j > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.