File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -336,3 +336,38 @@ func createTrimSet(chars ...rune) map[rune]bool {
336336
337337 return trimSet
338338}
339+
340+ // Set initial position
341+ func (s * StringBuilder ) Rewind () {
342+ s .position = 0
343+ }
344+
345+ // Sets the rune at the specific position
346+ func (s * StringBuilder ) SetRuneAt (index int , val rune ) error {
347+ if index < 0 {
348+ return fmt .Errorf ("index should always be greater than or equal to zero" )
349+ }
350+ if index > s .position {
351+ return fmt .Errorf ("index cannot be greater than current position" )
352+ }
353+ s .data [index ] = val
354+
355+ return nil
356+ }
357+
358+ // Change current position
359+ func (s * StringBuilder ) Skip (forward int ) error {
360+ if forward <= 0 {
361+ return fmt .Errorf ("forward should always be greater than zero" )
362+ }
363+
364+ newPos := s .position + forward
365+
366+ if newPos >= len (s .data ) {
367+ return fmt .Errorf ("cannot skip after end of string builder" )
368+ }
369+
370+ s .position = newPos
371+
372+ return nil
373+ }
You can’t perform that action at this time.
0 commit comments