mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-16 11:44:50 +02:00
add docs
This commit is contained in:
12
README.md
12
README.md
@@ -164,12 +164,12 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp
|
||||
- [util/lerp](https://openhome.cc/eGossip/OpenSCAD/lib3x-lerp.html)
|
||||
- [util/fibseq](https://openhome.cc/eGossip/OpenSCAD/lib3x-fibseq.html)
|
||||
- set
|
||||
- `util/set/hashset`
|
||||
- `util/set/hashset_add`
|
||||
- `util/set/hashset_has`
|
||||
- `util/set/hashset_del`
|
||||
- `util/set/hashset_len`
|
||||
- `util/set/hashset_elems`
|
||||
- [util/set/hashset](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset.html)
|
||||
- [util/set/hashset_add](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_add.html)
|
||||
- [util/set/hashset_has](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_has.html)
|
||||
- [util/set/hashset_del](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_del.html)
|
||||
- [util/set/hashset_len](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_len.html)
|
||||
- [util/set/hashset_elems](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_elems.html)
|
||||
- map
|
||||
- `util/map/hashmap`
|
||||
- `util/map/hashmap_put`
|
||||
|
38
docs/lib3x-hashset.md
Normal file
38
docs/lib3x-hashset.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# hashset
|
||||
|
||||
This function models the mathematical set, backed by a hash table. You can use the following to process the returned set.
|
||||
|
||||
- [util/set/hashset_add](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_add.html) : Add an element to the set. It returns a new set.
|
||||
- [util/set/hashset_has](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_has.html) : Returns `true` if the set contains the specified element.
|
||||
- [util/set/hashset_del](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_del.html) : Deletes the specified element. It returns a new set.
|
||||
- [util/set/hashset_len](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_len.html) : Returns the length of the set.
|
||||
- [util/set/hashset_elems](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_elems.html) : Returns a list containing all elements in the set. No guarantees to the order.
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `lt` : Constructs a new set containing the elements in the specified list.
|
||||
- `eq` : A equality function. If it's ignored, use `==` to compare elements.
|
||||
- `hash` : A hash function. If it's ignored, convert each element to a string and hash it.
|
||||
- `number_of_buckets` : The function uses a hash table internally. Change the number of buckets if you're trying to do optimization.
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/set/hashset.scad>;
|
||||
use <util/set/hashset_add.scad>;
|
||||
use <util/set/hashset_has.scad>;
|
||||
use <util/set/hashset_del.scad>;
|
||||
use <util/set/hashset_len.scad>;
|
||||
use <util/set/hashset_elems.scad>;
|
||||
|
||||
s1 = hashset([1, 2, 3, 4, 5, 2, 3, 5]);
|
||||
assert(hashset_len(s1) == 5);
|
||||
|
||||
s2 = hashset_add(s1, 9);
|
||||
assert(hashset_has(s2, 9));
|
||||
|
||||
s3 = hashset_del(s2, 2);
|
||||
assert(!hashset_has(s3, 2));
|
||||
|
||||
echo(hashset_elems(s3)); // a list contains 1, 3, 4, 5, 9
|
22
docs/lib3x-hashset_add.md
Normal file
22
docs/lib3x-hashset_add.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# hashset_add
|
||||
|
||||
This function adds an element to a [util/set/hashset](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset.html).It returns a new set containing the added element.
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `set` : The original set.
|
||||
- `elem` : Adds the specified element to the specified set.
|
||||
- `eq` : A equality function. If it's ignored, use `==` to compare elements.
|
||||
- `hash` : A hash function. If it's ignored, convert each element to a string and hash it.
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/set/hashset.scad>;
|
||||
use <util/set/hashset_add.scad>;
|
||||
use <util/set/hashset_has.scad>;
|
||||
|
||||
s1 = hashset([1, 2, 3, 4, 5]);
|
||||
s2 = hashset_add(s1, 9);
|
||||
assert(hashset_has(s2, 9));
|
22
docs/lib3x-hashset_del.md
Normal file
22
docs/lib3x-hashset_del.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# hashset_del
|
||||
|
||||
This function dels an element from a [util/set/hashset](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset.html).It returns a new set without the specified element.
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `set` : The original set.
|
||||
- `elem` : The element to be deleted.
|
||||
- `eq` : A equality function. If it's ignored, use `==` to compare elements.
|
||||
- `hash` : A hash function. If it's ignored, convert each element to a string and hash it.
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/set/hashset.scad>;
|
||||
use <util/set/hashset_del.scad>;
|
||||
use <util/set/hashset_has.scad>;
|
||||
|
||||
s1 = hashset([1, 2, 3, 4, 5]);
|
||||
s2 = hashset_del(s1, 3);
|
||||
assert(!hashset_has(s2, 3));
|
18
docs/lib3x-hashset_elems.md
Normal file
18
docs/lib3x-hashset_elems.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# hashset_has
|
||||
|
||||
Returns a list containing all elements in a [util/set/hashset](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset.html). No guarantees to the order.
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `set` : The set.
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/set/hashset.scad>;
|
||||
use <util/set/hashset_elems.scad>;
|
||||
|
||||
s = hashset([1, 2, 3, 4, 5]);
|
||||
echo(hashset_elems(s)); // a list contains 1, 2, 3, 4, 5
|
||||
|
20
docs/lib3x-hashset_has.md
Normal file
20
docs/lib3x-hashset_has.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# hashset_has
|
||||
|
||||
Returns `true` if a [util/set/hashset](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset.html) contains the specified element.
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `set` : The original set.
|
||||
- `elem` : The element to be checked.
|
||||
- `eq` : A equality function. If it's ignored, use `==` to compare elements.
|
||||
- `hash` : A hash function. If it's ignored, convert each element to a string and hash it.
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/set/hashset.scad>;
|
||||
use <util/set/hashset_has.scad>;
|
||||
|
||||
s = hashset([1, 2, 3, 4, 5]);
|
||||
assert(hashset_has(s, 3));
|
17
docs/lib3x-hashset_len.md
Normal file
17
docs/lib3x-hashset_len.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# hashset_has
|
||||
|
||||
Returns the length of the elements in a [util/set/hashset](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset.html).
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `set` : The set.
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/set/hashset.scad>;
|
||||
use <util/set/hashset_len.scad>;
|
||||
|
||||
s = hashset([1, 2, 3, 4, 5]);
|
||||
assert(hashset_len(s) == 5);
|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* hashset.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset.html
|
||||
*
|
||||
**/
|
||||
|
||||
use <../../__comm__/_str_hash.scad>;
|
||||
use <_impl/_hashset_impl.scad>;
|
||||
use <_impl/_hashset_add_impl.scad>;
|
||||
|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* hashset_add.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_add.html
|
||||
*
|
||||
**/
|
||||
|
||||
use <../../__comm__/_str_hash.scad>;
|
||||
use <_impl/_hashset_add_impl.scad>;
|
||||
|
||||
|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* hashset_del.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_del.html
|
||||
*
|
||||
**/
|
||||
|
||||
use <../../__comm__/_str_hash.scad>;
|
||||
use <../slice.scad>;
|
||||
use <../find_index.scad>;
|
||||
|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* hashset_elems.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_elems.html
|
||||
*
|
||||
**/
|
||||
|
||||
function hashset_elems(set) = [
|
||||
for(bucket = set)
|
||||
for(elem = bucket)
|
||||
|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* hashset_has.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_has.html
|
||||
*
|
||||
**/
|
||||
|
||||
use <../../__comm__/_str_hash.scad>;
|
||||
use <../some.scad>;
|
||||
|
||||
|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* hashset_len.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-hashset_len.html
|
||||
*
|
||||
**/
|
||||
|
||||
use <../sum.scad>;
|
||||
|
||||
function hashset_len(set) = sum([
|
||||
|
Reference in New Issue
Block a user