本文整理匯總了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();
}