An open API service indexing awesome lists of open source software.

https://github.com/shounlak/treeset-java

Learning TreeSet in Java
https://github.com/shounlak/treeset-java

huit java treeset

Last synced: 10 months ago
JSON representation

Learning TreeSet in Java

Awesome Lists containing this project

README

          

# Learning TreeSet in Java

A Java program demonstrating various operations on `TreeSet`, including sorting, searching, statistics, and manipulation using different data sources.

---

## 📌 Table of Contents
- [Features](#features)
- [Prerequisites](#prerequisites)
- [How to Run](#how-to-run)
- [Example Output](#example-output)
- [Contributors](#contributors)
- [License](#license)

---

## 🚀 Features

- **Default Ordering TreeSet**: Stores elements in ascending order.
- **Comparator-based TreeSet**: Stores elements in descending order using a custom comparator.
- **TreeSet from User Input**: Allows users to enter values via the keyboard.
- **Randomized TreeSet**: Generates random values and stores them.
- **TreeSet from an Array**: Converts an array into a `TreeSet` to remove duplicates.
- **TreeSet from a File**: Reads values from `input.txt` and stores them.
- **Search Operations**: Allows searching for elements in the TreeSet.
- **Deletion Operations**: Enables removing elements from the TreeSet.
- **Statistics on TreeSet**: Provides insights such as the smallest/largest elements and subsets.
- **Conversion to Array**: Transforms `TreeSet` into an array.
- **Clearing Elements**: Removes all elements from the TreeSet.

## 🛠 Prerequisites

- Java Development Kit (JDK) installed
- An `input.txt` file (if using file-based input)

## âš¡ How to Run

1. Clone this repository:
```sh
git clone https://github.com/ShouNLAK/Learning_TreeSet.git
```
2. Compile the Java program:
```sh
javac Learning_TreeSet.java
```
3. Run the program:
```sh
java Learning_TreeSet
```

## 📸 Example Output

```sh
TreeSet [1, 3, 4, 5, 8]
TreeSet with Comparator [8, 5, 4, 3, 1]
Number of elements:
Please input value of the elements #1: 23
TreeSet from keyboard input: [23]
Elements #1 randomized: 67
TreeSet from Random: [67]
...
```

## 👥 Contributors

- [ShouNLAK](https://github.com/ShouNLAK)
- Open to contributions! Feel free to fork, submit PRs, or suggest improvements.

## 📜 License

This project is open-source. Feel free to use and modify it as needed.