Skip to content

Implementation of the Rope data structure; allowing for generic elements

License

Notifications You must be signed in to change notification settings

CandleCandle/twine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twine

Generic library implementing a rope data structure.

Usage

Maven

Include a dependency in your pom.xml

<dependency>
    <groupId>uk.me.candle.twine</groupId>
    <artifactId>twine</artifactId>
    <version>[latest version]</version>
</dependency>

The latest version can be found on maven central: https://search.maven.org/search?q=g:uk.me.candle%20a:twine

Java

Rope<Character, CharSeqSliceable> rope = new BasicMutableRope<>();
// create a new empty Rope.

rope.append(new CharSeqSliceable("this is a rope element.\n"));
rope.append(new CharSeqSliceable("this is another rope element."));
// `rope` now contains "this is a rope element.\nthis is another rope element."

List<Character, CharSeqSliceable>> parts = rope.split(15);
// parts.get(0) now contains a Rope containing "this is a rope "
// parts.get(1) now contains a Rope containing " element.\nthis is another rope element."

Rope<Character, CharSeqSliceable> another = rope.insert(new CharSeqSliceable("\r"), 24);
// `another now contains "this is a rope element.\r\nthis is another rope element."

Extending

Implement the Sliceable interface for your array/list-like data structure.

public class MySliceable implements Sliceable<ElementType, MySliceable> { ... }

Create a Rope using it:

Rope<ElementType, MySliceable> rope = new BasicMutableRope<>();

About

Implementation of the Rope data structure; allowing for generic elements

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages