Skip to content
forked from vinzmay/go-rope

Golang implementation of a persistent rope data structure

License

Notifications You must be signed in to change notification settings

zyedidia/go-rope

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-rope v0.5

Description

Go implementation of a persistent rope data structure, useful to manipulate large text. Persistent means that any operation on the rope doesn't modify it, so it's inherently thread safe.

TODO: Rebalancing

Installation

Package can be installed with go command:

go get github.com/vinzmay/go-rope

Package documentation

GoDoc

Examples

Create a rope

	//Empty rope
	r1 := new(rope.Rope)
	
	//Initialized rope
	r2 := rope.New("test rope")

Concatenate two ropes

	r1 := rope.New("abc")
	r2 := rope.New("def")
	
	r3 := r1.Concat(r2) // "abcdef"

Split a rope

	r1 := rope.New("abcdef")
	
	r2, r3 := r1.Split(4) // "abcd", "ef"

Delete from a rope

	r1 := rope.New("abcdef")
	
	r2 := r1.Delete(3, 2) // "abef"

Insert in a rope

	r1 := rope.New("abcdef")
	
	r2 := r1.Insert(3, "xxx") // "abcxxxdef"

Rope substring

	r1 := rope.New("abcdef")
	
	r2 := r1.Substr(3, 2) // "cd"

About

Golang implementation of a persistent rope data structure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%