Skip to content

Commit ac782c7

Browse files
authored
✨ infra: add com.soobak.algo.search package and update import method to use Git path parameters (#21)
1 parent 4c99b92 commit ac782c7

10 files changed

Lines changed: 150 additions & 6 deletions

File tree

Packages/com.soobak.algo.core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"unity": "6000.0",
77
"author": {
88
"name": "Soobak",
9-
"email": "contact@soobak.dev"
9+
"email": "contact@soobakwalkway.com"
1010
},
1111
"keywords": [
1212
"algorithm",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Threading;
2+
using Cysharp.Threading.Tasks;
3+
using Soobak.Algo.Core;
4+
5+
namespace Soobak.Algo.Search {
6+
public interface ISearchAlgorithm<TItem, TKey> : IAlgorithm<SearchState<TItem, TKey>, SearchEvent<TItem, TKey>> {
7+
UniTask<SearchResult<TItem>?> SearchAsync(SearchState<TItem, TKey> state, TKey key, CancellationToken token);
8+
}
9+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace Soobak.Algo.Search {
2+
public sealed class SearchEvent<TItem, TKey> {
3+
public SearchEvent(SearchEventType type, TItem? item, int index, TKey searchKey, bool isMatch = false) {
4+
Type = type;
5+
Item = item;
6+
Index = index;
7+
SearchKey = searchKey;
8+
IsMatch = isMatch;
9+
}
10+
11+
public SearchEventType Type { get; }
12+
13+
public TItem? Item { get; }
14+
15+
public int Index { get; }
16+
17+
public TKey SearchKey { get; }
18+
19+
public bool IsMatch { get; }
20+
}
21+
22+
public enum SearchEventType {
23+
Examine,
24+
Found,
25+
NotFound,
26+
Complete
27+
}
28+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Soobak.Algo.Search {
2+
public sealed class SearchResult<TItem> {
3+
public SearchResult(TItem item, int index, int comparisons = 0) {
4+
Item = item;
5+
Index = index;
6+
Comparisons = comparisons;
7+
}
8+
9+
public TItem Item { get; }
10+
11+
public int Index { get; }
12+
13+
public int Comparisons { get; }
14+
}
15+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Soobak.Algo.Search {
5+
public sealed class SearchState<TItem, TKey> {
6+
public SearchState(IReadOnlyList<TItem> items, TKey searchKey, int currentIndex = 0, bool isComplete = false, SearchResult<TItem>? result = null) {
7+
Items = items;
8+
SearchKey = searchKey;
9+
CurrentIndex = currentIndex;
10+
IsComplete = isComplete;
11+
Result = result;
12+
}
13+
14+
public IReadOnlyList<TItem> Items { get; }
15+
16+
public TKey SearchKey { get; }
17+
18+
public int CurrentIndex { get; }
19+
20+
public bool IsComplete { get; }
21+
22+
public SearchResult<TItem>? Result { get; }
23+
24+
public SearchState<TItem, TKey> With(int? currentIndex = null, bool? isComplete = null, SearchResult<TItem>? result = null) {
25+
return new SearchState<TItem, TKey>(
26+
Items,
27+
SearchKey,
28+
currentIndex ?? CurrentIndex,
29+
isComplete ?? IsComplete,
30+
result ?? Result
31+
);
32+
}
33+
}
34+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Soobak.Algo.Search",
3+
"rootNamespace": "Soobak.Algo.Search",
4+
"references": [
5+
"Soobak.Algo.Core",
6+
"UniTask"
7+
],
8+
"includePlatforms": [],
9+
"excludePlatforms": [],
10+
"allowUnsafeCode": false,
11+
"overrideReferences": false,
12+
"precompiledReferences": [],
13+
"autoReferenced": true,
14+
"defineConstraints": [],
15+
"versionDefines": [],
16+
"noEngineReferences": false
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Soobak.Algo.Search.Tests",
3+
"rootNamespace": "Soobak.Algo.Search.Tests",
4+
"references": [
5+
"Soobak.Algo.Core",
6+
"Soobak.Algo.Search",
7+
"UniTask"
8+
],
9+
"includePlatforms": [],
10+
"excludePlatforms": [],
11+
"allowUnsafeCode": false,
12+
"overrideReferences": false,
13+
"precompiledReferences": [],
14+
"autoReferenced": true,
15+
"defineConstraints": [],
16+
"versionDefines": [],
17+
"noEngineReferences": false
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "com.soobak.algo.search",
3+
"displayName": "Soobak Algorithm Search",
4+
"description": "Search-specific implementations built on top of Soobak Algorithm Core.",
5+
"version": "0.1.0",
6+
"unity": "6000.0",
7+
"author": {
8+
"name": "Soobak",
9+
"email": "contact@soobakwalkway.com"
10+
},
11+
"keywords": [
12+
"search",
13+
"algorithm",
14+
"visualization"
15+
],
16+
"dependencies": {
17+
"com.soobak.algo.core": "0.1.0",
18+
"com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask#2.5.3"
19+
},
20+
"samples": []
21+
}

Packages/com.soobak.algo.sorting/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"unity": "6000.0",
77
"author": {
88
"name": "Soobak",
9-
"email": "contact@soobak.dev"
9+
"email": "contact@soobakwalkway.com"
1010
},
1111
"keywords": [
1212
"sorting",

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
[![Commit Signing](https://img.shields.io/badge/commits%20signed-verified-brightgreen)](https://github.com/soo-bak/soobak-algo-core/commits)
55

66

7-
Reusable Unity 6 algorithm pipeline. `com.soobak.algo.core` defines execution primitives, while `com.soobak.algo.sorting` ships a sorting domain showcase.
7+
Reusable Unity 6 algorithm pipeline. `com.soobak.algo.core` defines execution primitives, while `com.soobak.algo.sorting` and `com.soobak.algo.search` ship domain-specific showcases.
88

99
## Architecture Layers
1010
- **Core Primitives**: `IAlgorithm<TState, TEvent>` and `IAlgorithmStepSink<TState, TEvent>` contracts with `AlgorithmRunner<TState, TEvent>` handling snapshot cloning and fan-out.
1111
- **Core Pipeline**: `IAlgorithmDescriptor<TState, TEvent>`, `IAlgorithmCatalog<TState, TEvent>`, and `AlgorithmPipeline<TState, TEvent>` model how algorithms are registered, discovered, and executed.
1212
- **Sorting Module**: `SortingState`/`SortingItem`, `SortOp`, `IBarVisualizer`, `SortingAlgorithmCatalog`, and `SortingRunner` demonstrate the pipeline with bubble, selection, merge, heap, shell, counting, quick, and stable insertion sort implementations.
13+
- **Search Module**: `SearchState`/`SearchResult`, `SearchEvent`, `ISearchAlgorithm`, and search-specific implementations for linear search, binary search, and other search algorithms.
1314

1415
## Execution Flow
1516
1. `SortingAlgorithmCatalog` exposes descriptors created via `AlgorithmDescriptor.Create`.
@@ -18,12 +19,13 @@ Reusable Unity 6 algorithm pipeline. `com.soobak.algo.core` defines execution pr
1819
4. Each step broadcasts a cloned `SortingState` and a `SortOp` event so visualizers receive immutable snapshots.
1920

2021
## Usage
21-
1. Add Git UPM dependencies.
22+
1. Add Git UPM dependencies using path parameters.
2223
```json
2324
{
2425
"dependencies": {
25-
"com.soobak.algo.core": "https://github.com/soobak-algo/soobak-algo-core.git",
26-
"com.soobak.algo.sorting": "https://github.com/soobak-algo/soobak-algo-core.git?path=Packages/com.soobak.algo.sorting"
26+
"com.soobak.algo.core": "https://github.com/soo-bak/soobak-algo-core.git?path=Packages/com.soobak.algo.core",
27+
"com.soobak.algo.sorting": "https://github.com/soo-bak/soobak-algo-core.git?path=Packages/com.soobak.algo.sorting",
28+
"com.soobak.algo.search": "https://github.com/soo-bak/soobak-algo-core.git?path=Packages/com.soobak.algo.search"
2729
}
2830
}
2931
```

0 commit comments

Comments
 (0)