本文整理汇总了TypeScript中core/util/data_structures.Set类的典型用法代码示例。如果您正苦于以下问题:TypeScript Set类的具体用法?TypeScript Set怎么用?TypeScript Set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Set类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: change_active
change_active(i: number): void {
const active = new Set(this.model.active)
active.toggle(i)
this.model.active = active.values
if (this.model.callback != null)
this.model.callback.execute(this.model)
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:8,代码来源:checkbox_group.ts
示例2: patch_to_column
export function patch_to_column(col: Arrayable, patch: Patch[], shapes: Shape[]): Set<number> {
const patched: Set<number> = new Set()
let patched_range = false
for (const [ind, val] of patch) {
// make the single index case look like the length-3 multi-index case
let item: Arrayable, shape: Shape
let index: [number, number | Slice, number | Slice]
let value: unknown[]
if (isArray(ind)) {
const [i] = ind
patched.add(i)
shape = shapes[i]
item = col[i]
value = val as unknown[]
// this is basically like NumPy's "newaxis", inserting an empty dimension
// makes length 2 and 3 multi-index cases uniform, so that the same code
// can handle both
if (ind.length === 2) {
shape = [1, shape[0]]
index = [ind[0], 0, ind[1]]
} else
index = ind
} else {
if (isNumber(ind)) {
value = [val]
patched.add(ind)
} else {
value = val as unknown[]
patched_range = true
}
index = [0, 0, ind]
shape = [1, col.length]
item = col
}
// now this one nested loop handles all cases
let flat_index = 0
const [istart, istop, istep] = slice(index[1], shape[0])
const [jstart, jstop, jstep] = slice(index[2], shape[1])
for (let i = istart; i < istop; i += istep) {
for (let j = jstart; j < jstop; j += jstep) {
if (patched_range) {
patched.add(j)
}
item[(i*shape[1]) + j] = value[flat_index]
flat_index++
}
}
}
return patched
}
开发者ID:jsignell,项目名称:bokeh,代码行数:57,代码来源:column_data_source.ts
示例3: render_selection
render_selection(): void {
const selected = new Set(this.model.value)
for (const el of Array.from(this.el.querySelectorAll('option')))
el.selected = selected.has(el.value)
// Note that some browser implementations might not reduce
// the number of visible options for size <= 3.
this.select_el.size = this.model.size
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:10,代码来源:multiselect.ts
示例4: patch
patch(patches) {
const { data } = this
let patched = new Set()
for (const k in patches) {
const patch = patches[k]
patched = patched.union(patch_to_column(data[k], patch, this._shapes[k]))
}
this.setv({data}, {silent: true})
return this.patching.emit(patched.values)
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:10,代码来源:column_data_source.ts
示例5: patch
patch(patches: {[key: string]: [Index, any][]}): void {
const {data} = this
let patched: Set<number> = new Set()
for (const k in patches) {
const patch = patches[k]
patched = patched.union(patch_to_column(data[k], patch, this._shapes[k] as Shape[]))
}
this.setv({data}, {silent: true})
this.patching.emit(patched.values)
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例6: function
export const patch_to_column = function(col, patch, shapes) {
const patched = new Set()
let patched_range = false
for (let [ind, value] of patch) {
// make the single index case look like the length-3 multi-index case
let item, shape
if (!isArray(ind)) {
if (isNumber(ind)) {
value = [value]
patched.push(ind)
} else {
patched_range = true
}
ind = [0, 0, ind]
shape = [1, col.length]
item = col
} else {
patched.push(ind[0])
shape = shapes[ind[0]]
item = col[ind[0]]
}
// this is basically like NumPy's "newaxis", inserting an empty dimension
// makes length 2 and 3 multi-index cases uniform, so that the same code
// can handle both
if (ind.length === 2) {
shape = [1, shape[0]]
ind = [ind[0], 0, ind[1]]
}
// now this one nested loop handles all cases
let flat_index = 0
const [istart, istop, istep] = slice(ind[1], shape[0])
const [jstart, jstop, jstep] = slice(ind[2], shape[1])
for (let i = istart; i < istop; i += istep) {
for (let j = jstart; j < jstop; j += jstep) {
if (patched_range) {
patched.push(j)
}
item[(i*shape[1]) + j] = value[flat_index]
flat_index++
}
}
}
return patched
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:52,代码来源:column_data_source.ts
示例7: patch
patch(patches: PatchSet, setter_id?: string): void {
const {data} = this
let patched: Set<number> = new Set()
for (const k in patches) {
const patch = patches[k]
patched = patched.union(patch_to_column(data[k], patch, this._shapes[k] as Shape[]))
}
this.setv({data}, {silent: true})
this.patching.emit(patched.values)
if (this.document != null) {
const hint = new ColumnsPatchedEvent(this.document, this.ref(), patches)
this.document._notify_change(this, 'data', null, null, {setter_id, hint})
}
}
开发者ID:jsignell,项目名称:bokeh,代码行数:14,代码来源:column_data_source.ts
注:本文中的core/util/data_structures.Set类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论