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


TypeScript Map.get方法代碼示例

本文整理匯總了TypeScript中Immutable.Map.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Map.get方法的具體用法?TypeScript Map.get怎麽用?TypeScript Map.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Immutable.Map的用法示例。


在下文中一共展示了Map.get方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('accepts flattened pairs via of()', () => {
   var m: Map<any, any> = Map.of(1, 'a', 2, 'b', 3, 'c');
   expect(m.size).toBe(3);
   expect(m.get(1)).toBe('a');
   expect(m.get(2)).toBe('b');
   expect(m.get(3)).toBe('c');
 });
開發者ID:threehams,項目名稱:immutable-js,代碼行數:7,代碼來源:Map.ts

示例2: 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

示例3: cadd

    const director = (d: Map<State, Complex>, t: number)=>{
        const result = Map<State, Complex>().asMutable();

        // 量子ゆらぎの定數
        const gt0 = t / STEPS;
        const gt1 = 1 - gt0;
        // const gt = 100 * ((t+1) ** (-1.5)) - 0.1;   // t = 99 で0になる!

        // 方向
        for(let a=0; a<N; a++){
            // 位置
            for(let v=0, n=2**N; v<n; v++){
                // ===== H0
                // Sを適用する前の位置
                const vb = v ^ (1 << a);
                // vbの確率はGrover's diffusion operatorをかけて求める
                let s = czero;
                for(let b=0; b<N; b++){
                    const dd = a===b ? 2/N-1 : 2/N;
                    s = cadd(s, csmul(dd, d.get(makeState(b, vb), czero)));
                }
                s = csmul(gt0, s);

                // ===== H1
                let s2 = czero;
                for(let w=0; w<n; w++){
                    const dd = v===w ? 2/n-1 : 2/n;
                    s2 = cadd(s2, csmul(dd, d.get(makeState(a, w), czero)));
                }
                s = cadd(s, cmul(csmul(gt1, ci), s2));
                result.set(makeState(a, v), s);
            }
        }
        return result.asImmutable();
    };
開發者ID:uhyo,項目名稱:enshu3-quantum,代碼行數:35,代碼來源:annealing.ts

示例4:

 disks.filter((disk) =>  disk.get('online') && (
                             (
                                 !this.isDiskUsed(disk, diskUsage.get('attached')) &&
                                 !this.isDiskUsed(disk, diskUsage.get('boot')) &&
                                 !this.isDiskUsed(disk, diskUsage.get('reserved'))
                             ) || this.isDiskUsed(disk, diskUsage.get('freed'))
                         )
開發者ID:mactanxin,項目名稱:gui,代碼行數:7,代碼來源:disk-repository.ts

示例5: updateCanonical

  updateCanonical(callback: Function) {
    let canonical = this.cacheMap.get('canonical');
    let localData = this.cacheMap.get('local');

    let newCanonical = callback.call(null, canonical, localData);

    this.cacheMap = this.cacheMap.set(CANONICAL, newCanonical);
  }
開發者ID:fivetanley,項目名稱:diamond,代碼行數:8,代碼來源:diamond.ts

示例6: removeConnection

    removeConnection(parent: any, child: any) {
        var parents = this.parents.get(child.id);
        var parentsAll = this.parents.set(child.id, parents.filter(ancestor => ancestor !== parent).toList());
        var children = this.children.get(parent.id);
        var childrenAll = this.children.set(parent.id, children.filter(ch => ch !== child).toList());

        return new Graph(this.nodes, childrenAll, parentsAll);
    }
開發者ID:gsanta,項目名稱:gsgraph,代碼行數:8,代碼來源:Graph.ts

示例7: getParent

    getParent(node: any) {
        var parents = this.parents.get(node.id);

        if (parents.size === 0) {
            return null;
        }

        return parents.get(0);
    }
開發者ID:gsanta,項目名稱:gsgraph,代碼行數:9,代碼來源:Graph.ts

示例8: model

  model(name?: string): type.Model | undefined {
    if (!name) {
      name = 'main';
    }
    if (this.models.has(name)) {
      return this.models.get(name);
    }

    return this.models.get('stdlib·' + name);
  }
開發者ID:sdlabs,項目名稱:sd.js,代碼行數:10,代碼來源:project.ts


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