SplayTrees

A SplayTree implementation

License

License

GroupId

GroupId

com.nachinius
ArtifactId

ArtifactId

splaytrees_2.12
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

SplayTrees
A SplayTree implementation
Project URL

Project URL

https://github.com/nachinius/SplayTrees
Project Organization

Project Organization

com.nachinius
Source Code Management

Source Code Management

https://github.com/nachinius/SplayTrees

Download splaytrees_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.nachinius/splaytrees_2.12/ -->
<dependency>
    <groupId>com.nachinius</groupId>
    <artifactId>splaytrees_2.12</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.nachinius/splaytrees_2.12/
implementation 'com.nachinius:splaytrees_2.12:0.1.1'
// https://jarcasting.com/artifacts/com.nachinius/splaytrees_2.12/
implementation ("com.nachinius:splaytrees_2.12:0.1.1")
'com.nachinius:splaytrees_2.12:jar:0.1.1'
<dependency org="com.nachinius" name="splaytrees_2.12" rev="0.1.1">
  <artifact name="splaytrees_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.nachinius', module='splaytrees_2.12', version='0.1.1')
)
libraryDependencies += "com.nachinius" % "splaytrees_2.12" % "0.1.1"
[com.nachinius/splaytrees_2.12 "0.1.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4

test (2)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.4
org.scalacheck : scalacheck_2.12 jar 1.13.4

Project Modules

There are no modules declared in this project.

Build Status codecov Coverage Status Join the chat at https://gitter.im/SplayTrees/Lobby Latest version

Splay Tree

A splay-tree is a BST, self adjusting, that has

  • the working-set property
  • the dynamic-finger property
  • conjectured to be dynamically optimal
  • conjectured to have unified property

install with sbt

    val splayTreesVersion = "0.1.1"
    libraryDependencies += "com.nachinius" %% "splaytrees" % splayTreesVersion

usage

import com.nachinius.splay.Node

val objTres = new Node[Int,String](3,"tres")
val objCinco = objTres.insert(5,"cinco")

// better to insert in last inserted node (which is the root). Nevertheless you may insert anywhere, but if you use a node that is not already the root, the system will invoke an extra `splay` call

val objSeven = objCinco.insert(7, "siete")
// equivalent (in result, not performance) to
// val objSeven = objTress.insert(7,"siete")

//----
// To add a sequence of tuples (key: Key, value: Value)
val seq: (Key, Value)
seq.foldLeft(objTres) {
  case (n, (k,v)) => n.insert(k,v)
}
// e.g.
val seed = 1475648325L
val rnd = new scala.util.Random(seed)
val maxNumber = 10000
val last = Seq.fill(100)(rnd.nextInt(maxNumber)).foldLeft(objTres) {
 case (n, (k,v)) => n.insert(k, v.toString)
}
//--- 

//And then you can search
last.search(5)

// split at ndoe
last.split

// or split at a found value (we have inserted 7 before)
val optCuttedTree = last.search(7).map(_.split)

// you can call splay directly in any node, (if you have athe node reference)
last.splay

what is a Splay Tree

References

[1] Advanced Data Structures, MIT 6.851, Prof. Erik Demaine Lecture 19

[2] https://en.wikipedia.org/wiki/Splay_tree (retrieved 2018-february-05):

Versions

Version
0.1.1
0.1