QidSet
Class in @bimworks/jssdk.
API catalogue · @bimworks/jssdk · Class
QidSet represents a Set of Qid. The main reasons why this class exists and should be used are:
- A regular Set can not handle custom objects such as Qid
- The internal implementation of QidSet is a lot more efficient than a generic Set object (it can do so because it is aware of what type is stored)
This object is Set-like (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#set-like_objects)
The methods on this class are also as much as possible identical to that of the built-in Set class.
Members#
| Member | Kind | Description |
|---|---|---|
| constructor | Method | |
| constructor | Method | |
| first | Method | |
| size | Method | |
| empty | Method | Returns a reference to an empty QidSet which should be regarded a unmodifiable. This can be used to avoid allocations. |
| [iterator] | Method | |
| add | Method | Add a Qid to this set |
| addAll | Method | Add all the Qids of the given QidSet to this QidSet |
| addByVidOid | Method | Add a Qid to this set. This method does the same thing as the add(qid) method but can be slightly more efficient in cases where no Qid is available |
| clear | Method | Remove all Qids from this QidSet |
| clone | Method | A copy of this set |
| delete | Method | Remove a Qid from this QidSet |
| difference | Method | The difference() method of QidSet instances takes a QidSet and returns a new QidSet containing elements in this QidSet but not in the given QidSet. |
| dispose | Method | Releases the bitmap memory (WebAssembly) behind this set; the set must not be used afterwards |
| entries | Method | The entries() method of QidSet instances returns a new set iterator object that contains an array of [qid, qid] for each element in this set. For QidSet obje… |
| filter | Method | Create a new QidSet by filtering the current QidSet. |
| forEach | Method | The forEach() method of QidSet instances executes a provided function once for each Qid in this set |
| getVersionUuidSet | Method | A convenience method that extracts all the unique Vid's of the Qids in this QidSet |
| has | Method | Check whether this QidSet contains the given Qid |
| hasVidOid | Method | Whether the set holds the object oid of version vid |
| intersection | Method | Calculate the intersection of two QidSets; All Qid's that are in both QidSet. |
| isEmpty | Method | |
| keys | Method | The keys() method of QidSet instances is an alias for the values() method. |
| renameVid | Method | Moves the objects of version oldVid to newVid, for example after a version was replaced by its successor |
| splitByVid | Method | This set split per version: each subset holds only that version's objects |
| toParameterValue | Method | The plain-JSON form the server binds as a query parameter (see QueryHelper.toParameterValues) |
| toQidCondition | Method | Generate a string that can be used in a BQL condition Example use: "buildingStorey.qid " + floorQids.toQidCondition() + " AND type != IFCSPACE" |
| toQuotedString | Method | Generates a string representation of this QidSet in the form of a comma-separated and per-Qid double-quoted string Example: A QidSet with 2 QIDs would be rep… |
| union | Method | Union two QidSets |
| unionInline | Method | Union two QidSets, this QidSet is modified |
| values | Method | The values() method of QidSet instances returns a new set iterator object that contains the values for each element in this set. |
| of | Method | A new set holding one Qid |
| ofAlt | Method | A set of the objects given per model, {versionUuid: oids}: the form API results (a BVL result's show, hide, select ...) send object sets in |
| ofIterable | Method | Create a new QidSet by providing an Iterable, the values in the Iterable must be either: - Valid Qid Strings - Qid instances - JS Objects that have both the … |
constructor#
constructor()constructor#
Parameters#
| Name | Type | Description |
|---|---|---|
iterable |
Iterable<Qid> |
first#
Returns#
The first Qid in this QidSet. Keep in mind that order in a QidSet is not guaranteed thus this method really should only be used in cases where the QidSet is of size 1
size#
size(): numberReturns#
The current size of this QidSet (number of Qids in it)
empty#
Returns a reference to an empty QidSet which should be regarded a unmodifiable. This can be used to avoid allocations.
[iterator]#
add#
Add a Qid to this set
Parameters#
| Name | Type | Description |
|---|---|---|
qid |
Qid | The Qid to add |
Returns#
Whether the Qid was added, only returns false when the Qid was already in the set
addAll#
Add all the Qids of the given QidSet to this QidSet
Parameters#
| Name | Type | Description |
|---|---|---|
qids |
QidSet | Another QidSet |
Returns#
The number of Qids that were added (already existing ones not counted)
addByVidOid#
addByVidOid(vid: string, oid: number): booleanAdd a Qid to this set. This method does the same thing as the add(qid) method but can be slightly more efficient in cases where no Qid is available
Parameters#
| Name | Type | Description |
|---|---|---|
vid |
string |
The Vid (Version UUID) |
oid |
number |
The Oid (Object ID) |
Returns#
Whether the Qid was added, only returns false when the Qid was already in the set
clear#
clear(): voidRemove all Qids from this QidSet
clone#
A copy of this set
delete#
Remove a Qid from this QidSet
Parameters#
| Name | Type | Description |
|---|---|---|
qid |
Qid | The Qid to remove |
Returns#
Whether the Qid was removed, returns false when the Qid did not exist in the QidSet
difference#
The difference() method of QidSet instances takes a QidSet and returns a new QidSet containing elements in this QidSet but not in the given QidSet.
Parameters#
| Name | Type | Description |
|---|---|---|
other |
QidSet | The other QidSet to subtract |
dispose#
dispose(): voidReleases the bitmap memory (WebAssembly) behind this set; the set must not be used afterwards
entries#
The entries() method of QidSet instances returns a new set iterator object that contains an array of [qid, qid] for each element in this set. For QidSet objects there is no key like in QidMap objects. However, to keep the API similar to the QidMap object, each entry has the same value for its key and value here, so that an array [qid, qid] is returned.
filter#
Create a new QidSet by filtering the current QidSet.
Parameters#
| Name | Type | Description |
|---|---|---|
callbackFn |
(qid: Qid) => boolean |
A function that should return true for elements that should be included, when no callbackFn is passed all Qids will be included |
Returns#
A new QidSet with the filtered Qids
forEach#
The forEach() method of QidSet instances executes a provided function once for each Qid in this set
Parameters#
| Name | Type | Description |
|---|---|---|
callbackFn |
(qid: Qid) => boolean |
|
thisArg |
unknown |
getVersionUuidSet#
getVersionUuidSet(): Set<string>A convenience method that extracts all the unique Vid's of the Qids in this QidSet
Returns#
A Set containing the unqiue Vid's in this QidSet
has#
Check whether this QidSet contains the given Qid
Parameters#
| Name | Type | Description |
|---|---|---|
qid |
Qid | The Qid to check |
Returns#
Whether this QidSet contains the given Qid
hasVidOid#
hasVidOid(vid: string, oid: number): booleanWhether the set holds the object oid of version vid
Parameters#
| Name | Type | Description |
|---|---|---|
vid |
string |
|
oid |
number |
intersection#
Calculate the intersection of two QidSets; All Qid's that are in both QidSet.
Parameters#
| Name | Type | Description |
|---|---|---|
other |
QidSet | The other QidSet |
Returns#
A new QidSet with the intersection of this QidSet and the other QidSet
isEmpty#
isEmpty(): booleankeys#
The keys() method of QidSet instances is an alias for the values() method.
renameVid#
renameVid(oldVid: string, newVid: string): voidMoves the objects of version oldVid to newVid, for example after a version was replaced by its successor
Parameters#
| Name | Type | Description |
|---|---|---|
oldVid |
string |
|
newVid |
string |
splitByVid#
This set split per version: each subset holds only that version's objects
toParameterValue#
toParameterValue(): ({ oids: (number)[]; vid: string })[]The plain-JSON form the server binds as a query parameter (see QueryHelper.toParameterValues)
toQidCondition#
toQidCondition(): stringGenerate a string that can be used in a BQL condition
Example use: "buildingStorey.qid " + floorQids.toQidCondition() + " AND type != IFCSPACE"
toQuotedString#
toQuotedString(allowCompact?: boolean): stringGenerates a string representation of this QidSet in the form of a comma-separated and per-Qid double-quoted string
Example: A QidSet with 2 QIDs would be represented as: "227e071d-4909-4b5c-8d48-46f44d027c46-1", "227e071d-4909-4b5c-8d48-46f44d027c46-2"
The returned String is usually used to plug into a String representation of a BQL (BIM.works Query Language) query, for example:
GET attribute.Name WHERE qid IN ("227e071d-4909-4b5c-8d48-46f44d027c46-1", "227e071d-4909-4b5c-8d48-46f44d027c46-2")
When allowCompact is enabled the same QidSet would be represented as: "227e071d-4909-4b5c-8d48-46f44d027c46"[1, 2], which is also valid in a BQL query
Parameters#
| Name | Type | Description |
|---|---|---|
allowCompact |
boolean |
Whether the implementation is allowed to use the compact representation, defaults to true |
Returns#
A String representation of this QidSet
union#
Union two QidSets
Parameters#
| Name | Type | Description |
|---|---|---|
other |
QidSet |
Returns#
A new QidSet object containing elements which are in either this QidSet or in the other QidSet.
unionInline#
Union two QidSets, this QidSet is modified
Parameters#
| Name | Type | Description |
|---|---|---|
other |
QidSet |
Returns#
This QidSet object containing elements which are in either this QidSet or in the other QidSet.
values#
The values() method of QidSet instances returns a new set iterator object that contains the values for each element in this set.
of#
A new set holding one Qid
Parameters#
| Name | Type | Description |
|---|---|---|
qid |
string | Qid |
ofAlt#
A set of the objects given per model, {versionUuid: oids}: the form API results (a BVL result's show, hide, select ...) send object sets in
Parameters#
| Name | Type | Description |
|---|---|---|
qids |
{ [versionUuid: string]: Iterable<number, any, any> } |
ofIterable#
Create a new QidSet by providing an Iterable, the values in the Iterable must be either:
- Valid Qid Strings
- Qid instances
- JS Objects that have both the vid:string and oid:number properties
Parameters#
| Name | Type | Description |
|---|---|---|
iterable |
Iterable<string | object | Qid> |
Returns#
A QidSet of all the Qids in the Iterable