https://github.com/init-io/thirdbrac
**thirdBrac** is a Python-style list library for Java, bringing the simplicity of Pythonβs `list` to Java. It supports all major list operations, slicing, and functional programming, making Java list handling intuitive and efficient. π
https://github.com/init-io/thirdbrac
java javalib javalibrary javalistsort list listing programming python
Last synced: 8 months ago
JSON representation
**thirdBrac** is a Python-style list library for Java, bringing the simplicity of Pythonβs `list` to Java. It supports all major list operations, slicing, and functional programming, making Java list handling intuitive and efficient. π
- Host: GitHub
- URL: https://github.com/init-io/thirdbrac
- Owner: Init-io
- License: mit
- Created: 2025-02-19T06:58:44.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-19T07:10:38.000Z (8 months ago)
- Last Synced: 2025-02-19T07:32:57.060Z (8 months ago)
- Topics: java, javalib, javalibrary, javalistsort, list, listing, programming, python
- Language: Java
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **π₯ thirdBrac - Pythonic Lists in Java (v1.0.0) π₯**


[](LICENSE)

**π A fully Python-style list implementation for Java!**
Now you can use lists like a **Python pro in Java!** π
---
## **π Features**
β
**Simple & Pythonic:** Works just like Pythonβs `list`
β
**Fully Featured:** Supports all major list operations
β
**Iterable & Functional:** Supports `for-each`, `map`, `filter`, `reduce`
β
**Super Fast & Optimized!**
---
## **π Installation**
Just download `thirdBrac.java` and add it to your project.
---
## **π Quick Example**
```java
import io.github.initio.thirdBrac.thirdBrac;
public class Main {
public static void main(String[] args) {
thirdBrac myList = thirdBrac.list(1, 2, 3, 4, 5);
myList.append(6);
myList.insert(2, 99);
myList.extend(Arrays.asList(7, 8));
System.out.println(myList); // [1, 2, 99, 3, 4, 5, 6, 7, 8]
}
}
```
---
## **π Complete List of Methods in `thirdBrac`**
---
### **1οΈβ£ Creation Methods**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `thirdBrac.list(T... elements)` | Creates a `thirdBrac` list | `thirdBrac myList = thirdBrac.list(1, 2, 3, 4, 5);` |
| `thirdBrac.of(T... elements)` | Alternate way to create a `thirdBrac` list | `thirdBrac myList = thirdBrac.of(1, 2, 3);` |
---
### **2οΈβ£ Basic Operations**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `append(T value)` | Adds an element at the end | `myList.append(6);` |
| `insert(int index, T value)` | Inserts an element at a specific index | `myList.insert(2, 99);` |
| `extend(List values)` | Extends list by adding multiple elements | `myList.extend(Arrays.asList(7, 8));` |
| `remove(T value)` | Removes the first occurrence of the value | `myList.remove(3);` |
| `pop()` | Removes and returns the last element | `T popped = myList.pop();` |
| `pop(int index)` | Removes and returns element at index | `T popped = myList.pop(2);` |
| `clear()` | Clears the entire list | `myList.clear();` |
| `set(int index, T value)` | Replaces an element at a given index | `myList.set(1, 100);` |
| `get(int index)` | Gets an element at a given index | `T first = myList.get(0);` |
---
### **3οΈβ£ Indexing & Slicing**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `first()` | Returns the first element | `T first = myList.first();` |
| `last()` | Returns the last element | `T last = myList.last();` |
| `slice(int start, int end)` | Returns a sublist (Python slicing) | `thirdBrac subList = myList.slice(1, 4);` |
| `reverseSlice()` | Returns a reversed copy of the list | `thirdBrac reversedList = myList.reverseSlice();` |
---
### **4οΈβ£ Searching & Counting**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `index(T value)` | Returns index of the first occurrence | `int idx = myList.index(100);` |
| `count(T value)` | Counts occurrences of a value | `int occurrences = myList.count(2);` |
| `contains(T value)` | Checks if the list contains a value | `boolean isPresent = myList.contains(5);` |
---
### **5οΈβ£ Sorting & Reversing**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `sort()` | Sorts list in ascending order | `myList.sort();` |
| `sortDescending()` | Sorts list in descending order | `myList.sortDescending();` |
| `reverse()` | Reverses the list | `myList.reverse();` |
---
### **6οΈβ£ Copying & Merging**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `copy()` | Returns a copy of the list | `thirdBrac copyList = myList.copy();` |
| `merge(List otherList)` | Merges two lists | `thirdBrac merged = myList.merge(Arrays.asList(10, 11));` |
---
### **7οΈβ£ Functional Programming**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `map(Function func)` | Applies a function to each element | `thirdBrac squared = myList.map(x -> x * x);` |
| `filter(Predicate predicate)` | Filters elements based on condition | `thirdBrac evens = myList.filter(x -> x % 2 == 0);` |
| `reduce(BinaryOperator reducer)` | Aggregates values | `Optional sum = myList.reduce(Integer::sum);` |
---
### **8οΈβ£ List Comprehensions (Python-Style)**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `comprehension(int start, int end, IntFunction func)` | Generates a list using a function | `thirdBrac squares = thirdBrac.comprehension(0, 5, x -> x * x);` |
---
### **9οΈβ£ Conversion**
| **Method** | **Description** | **Usage Example** |
|-----------|--------------|-----------------|
| `toList()` | Converts `thirdBrac` to a Java `List` | `List normalList = myList.toList();` |
---
### **π Iteration (For-each Loop Support)**
```java
for (Integer num : myList) {
System.out.println(num);
}
```
---
## **π FULL USAGE EXAMPLES**
```java
public class Main {
public static void main(String[] args) {
thirdBrac myList = thirdBrac.list(1, 2, 3, 4, 5);
myList.append(6);
myList.insert(2, 99);
myList.extend(Arrays.asList(7, 8));
myList.remove(3);
System.out.println(myList); // [1, 2, 99, 4, 5, 6, 7, 8]
System.out.println("Popped: " + myList.pop()); // 8
System.out.println(myList.slice(1, 4)); // [2, 99, 4]
System.out.println("First: " + myList.first()); // 1
System.out.println("Last: " + myList.last()); // 7
System.out.println("Index of 99: " + myList.index(99)); // 2
myList.reverse();
System.out.println("Reversed: " + myList); // [7, 6, 5, 4, 99, 2, 1]
thirdBrac squares = thirdBrac.comprehension(0, 5, x -> x * x);
System.out.println("Squares: " + squares); // [0, 1, 4, 9, 16]
}
}
```
---
## **π thirdBrac is the ULTIMATE PYTHONIC LIST LIBRARY FOR JAVA!**
π₯ **Just import and code like a Python GOD in Java!** π₯
π **Version:** `1.0.0`
π **Author:** *Siam Rayhan*
π **License:** MIT