本文整理汇总了TypeScript中Immutable.Map.forEach方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Map.forEach方法的具体用法?TypeScript Map.forEach怎么用?TypeScript Map.forEach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.Map
的用法示例。
在下文中一共展示了Map.forEach方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: removeNode
removeNode(node: any) {
var nodesAll = this.nodes.filter(n => n !== node).toList();
var parentsAll: Map<number, List<Node>> = this.parents;
var childrenAll: Map<number, List<Node>> = this.children;
var parents = parentsAll.get(node.id);
parents.forEach((parent) => {
var children = childrenAll.get(parent.id);
children = children.filter((child) => child !== node).toList();
childrenAll = childrenAll.set(parent.id, children);
});
parentsAll = parentsAll.set(node.id, List<any>());
var children = childrenAll.get(node.id);
children.forEach((child) => {
var parents = parentsAll.get(child.id);
parents = parents.filter((ancestor) => ancestor !== node).toList();
parentsAll = parentsAll.set(child.id, parents);
});
childrenAll = childrenAll.remove(node.id);
return new Graph(nodesAll, childrenAll, parentsAll);
}
示例2: filterVisibleCustomFields
private filterVisibleCustomFields(issue: BoardIssueView): boolean {
let visible = true;
this._customFieldFilters.forEach((f, k) => {
const cfv: CustomField = issue.customFields.get(k);
if (!f.doFilter(cfv ? cfv.key : null)) {
visible = false;
return false;
}
});
return visible;
}
示例3: filterVisibleParallelTasks
private filterVisibleParallelTasks(issue: BoardIssueView): boolean {
let visible = true;
const indicesForProject: Map<string, number> = this._parallelTaskFilterIndicesByProject.get(issue.projectCode);
this._parallelTaskFilters.forEach((f, k) => {
if (indicesForProject) {
const index: number = indicesForProject.get(k);
if (!issue.parallelTasks ||
!f.doFilter(issue.parallelTasks.get(index).options.get(issue.selectedParallelTasks.get(index)).name)) {
visible = false;
return false;
}
}
});
return visible;
}
示例4: addFile
addFile(xmileDoc: XMLDocument, isMain = false): [Project, undefined] | [undefined, Error] {
const [file, err] = Project.parseFile(xmileDoc);
if (err) {
return [undefined, err];
}
const files = this.files.push(defined(file));
// FIXME: merge the other parts of the model into the project
const models = Map(
defined(file).models.map(
(xModel): [string, Model] => {
const model = new Model(this, xModel);
return [model.ident, model];
},
),
);
let dupErr: Error | undefined;
models.forEach((model, name) => {
if (this.models.has(name)) {
dupErr = new Error(`duplicate name ${name}`);
}
});
if (dupErr) {
return [undefined, dupErr];
}
const xMod = new xmile.Variable({
type: 'module',
name: 'main',
});
const main = new Module(xMod);
let newProject = this.mergeDeep({
files,
models: this.models.merge(models),
main,
});
if (models.has('main') && defined(file).header && defined(defined(file).header).name) {
newProject = newProject.set('name', defined(defined(file).header).name);
}
return [newProject, undefined];
}
示例5: getDir
const director = (d: Map<State, Complex>)=>{
const result = Map<State, Complex>().asMutable();
d.forEach((r: Complex, k: State)=>{
const a = getDir(k);
const v = getPos(k);
// Hadamard operatorを適用してShift
const s1 = makeState(0, v-1);
const s2 = makeState(1, v+1);
/*
const dl = a===0 ? cone : czero;
const dr = a===1 ? cone : czero;
result.set(s1, cadd(cadd(dl, dr), result.get(s1, czero)));
result.set(s2, cadd(csub(dl, dr), result.get(s2, czero)));
*/
result.set(s1, cadd(r, result.get(s1, czero)));
result.set(s2, cadd(a===0 ? r : csmul(-1, r), result.get(s2, czero)));
});
return result.asImmutable();
}