當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript data_structures.Set類代碼示例

本文整理匯總了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;未經允許,請勿轉載。