当前位置: 首页>>代码示例>>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;未经允许,请勿转载。