本文整理匯總了TypeScript中core/util/data_structures.Set.push方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Set.push方法的具體用法?TypeScript Set.push怎麽用?TypeScript Set.push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core/util/data_structures.Set
的用法示例。
在下文中一共展示了Set.push方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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
}