io.github.starlangsoftware:DataStructure

Simple Data Structures Library


Keywords
cache, data-structure
License
Apache-2.0

Documentation

For Developers

You can also see Python, Cython, C++, Swift, Js, or C# repository.

Class Diagram

Requirements

Java

To check if you have a compatible version of Java installed, use the following command:

java -version

If you don't have a compatible version, you can download either Oracle JDK or OpenJDK

Maven

To check if you have Maven installed, use the following command:

mvn --version

To install Maven, you can follow the instructions here.

Git

Install the latest version of Git.

Download Code

In order to work on code, create a fork from GitHub page. Use Git for cloning the code to your local or below line for Ubuntu:

git clone <your-fork-git-link>

A directory called DataStructure will be created. Or you can use below link for exploring the code:

git clone https://github.com/starlangsoftware/DataStructure.git

Open project with IntelliJ IDEA

Steps for opening the cloned project:

  • Start IDE
  • Select File | Open from main menu
  • Choose DataStructure/pom.xml file
  • Select open as project option
  • Couple of seconds, dependencies with Maven will be downloaded.

Compile

From IDE

After being done with the downloading and Maven indexing, select Build Project option from Build menu. After compilation process, user can run DataStructure.

From Console

Go to DataStructure directory and compile with

 mvn compile 

Generating jar files

From IDE

Use package of 'Lifecycle' from maven window on the right and from DataStructure root module.

From Console

Use below line to generate jar file:

 mvn install

Maven Usage

    <dependency>
        <groupId>io.github.starlangsoftware</groupId>
        <artifactId>DataStructure</artifactId>
        <version>1.0.2</version>
    </dependency>

Detailed Description

CounterHashMap

CounterHashMap bir veri tipinin kaç kere geçtiğini hafızada tutmak için kullanılmaktadır.

Bir CounterHashMap yaratmak için

a = CounterHashMap();

Hafızaya veri eklemek için

void put(K key)

Örneğin,

a.put("ali");

Bu aşamanın ardından "ali" nin sayacı 1 olur.

Hafızaya o veriyi birden fazla kez eklemek için

void putNTimes(K key, int N)

Örneğin,

a.putNTimes("veli", 5)

Bu aşamanın ardından "ali"'nin sayacı 5 olur.

Hafızada o verinin kaç kere geçtiğini bulmak için

int count(K key)

Örneğin, "veli" nin kaç kere geçtiğini bulmak için

kacKere = a.count("veli")

Bu aşamanın ardından kacKere değişkeninin değeri 5 olur.

Hafızada hangi verinin en çok geçtiğini bulmak için

K max()

Örneğin,

kelime = a.max()

Bu aşamanın ardından kelime "veli" olur.

LRUCache

LRUCache veri cachelemek için kullanılan bir veri yapısıdır. LRUCache en yakın zamanda kullanılan verileri öncelikli olarak hafızada tutar. Bir LRUCache yaratmak için

LRUCache(int cacheSize)

kullanılır. cacheSize burada cachelenecek verinin büyüklüğünün limitini göstermektedir.

Cache'e bir veri eklemek için

void add(K key, T data)

kullanılır. data burada eklenecek veriyi, key anahtar göstergeyi göstermektedir.

Cache'de bir veri var mı diye kontrol etmek için

boolean contains(K key)

kullanılır.

Cache'deki veriyi anahtarına göre getirmek için

T get(K key)

kullanılır.