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


TypeScript Map.forEach方法代碼示例

本文整理匯總了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);
    }
開發者ID:gsanta,項目名稱:gsgraph,代碼行數:26,代碼來源:Graph.ts

示例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;
 }
開發者ID:rsvoboda,項目名稱:overbaard-redux,代碼行數:11,代碼來源:filter.util.ts

示例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;
 }
開發者ID:rsvoboda,項目名稱:overbaard-redux,代碼行數:15,代碼來源:filter.util.ts

示例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];
  }
開發者ID:sdlabs,項目名稱:sd.js,代碼行數:46,代碼來源:project.ts

示例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();
}
開發者ID:uhyo,項目名稱:enshu3-quantum,代碼行數:20,代碼來源:hadamard-walk.ts


注:本文中的Immutable.Map.forEach方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。