当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Uint64.toString方法代码示例

本文整理汇总了TypeScript中neuroglancer/util/uint64.Uint64.toString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Uint64.toString方法的具体用法?TypeScript Uint64.toString怎么用?TypeScript Uint64.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neuroglancer/util/uint64.Uint64的用法示例。


在下文中一共展示了Uint64.toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('HashSetUint64', () => {
    let ht = new HashSetUint64();
    let set = new Set<string>();

    function compareViaIterate() {
      let htValues = new Set<string>();
      for (let v of ht) {
        let s = v.toString();
        expect(htValues.has(s)).toBe(false, `Duplicate key in hash table: ${s}`);
        expect(set.has(s)).toBe(true, `Unexpected key ${s} in hash table`);
        htValues.add(s);
      }
      for (let s of set) {
        expect(htValues.has(s)).toBe(true, `Hash table is missing key ${s}`);
      }
    }

    function compareViaHas() {
      for (let s of set) {
        let k = Uint64.parseString(s);
        expect(ht.has(k)).toBe(true, `Hash table is missing key ${s}`);
      }
    }

    function compare() {
      compareViaIterate();
      compareViaHas();
    }
    let numInsertions = 100;

    function testInsert(k: Uint64) {
      let s = '' + k;
      set.add(s);
      expect(ht.has(k)).toBe(false, `Unexpected positive has result for ${[k.low, k.high]}`);
      ht.add(k);
      compare();
    }

    let empty0 = new Uint64(ht.emptyLow, ht.emptyHigh);
    testInsert(empty0);

    for (let i = 0; i < numInsertions; ++i) {
      let k: Uint64;
      let s: string;
      while (true) {
        k = Uint64.random();
        s = k.toString();
        if (!set.has(s)) {
          break;
        }
      }
      testInsert(k);
    }

    let empty1 = new Uint64(ht.emptyLow, ht.emptyHigh);
    testInsert(empty1);

  });
开发者ID:google,项目名称:neuroglancer,代码行数:58,代码来源:hash_table.spec.ts

示例2: compareViaIterate

 function compareViaIterate() {
   let htValues = new Map();
   for (let [low, high] of ht) {
     let v = new Uint64(low, high);
     let s = v.toString();
     if (htValues.has(s)) {
       throw new Error('Duplicate key in hash table: ' + [low, high]);
     }
     if (!map.has(s)) {
       throw new Error('Unexpected key ' + [low, high] + ' in hash table');
     }
     htValues.set(s, v);
   }
   for (let [s, k] of map) {
     if (!htValues.has(s)) {
       throw new Error('Hash table is missing key ' + [k.low, k.high]);
     }
   }
 }
开发者ID:funkey,项目名称:neuroglancer,代码行数:19,代码来源:hash_table.spec.ts

示例3: it

  it('toString parseString round trip', () => {
    function check(x: Uint64, base: number) {
      let s = x.toString(base);
      let y = Uint64.parseString(s, base);
      expect(y.low).toBe(x.low, `s=${s}, x.low=${x.low}, x.high=${x.high}, y.low=${y.low}, y.high=${y.high}, base=${base}`);
      expect(y.high).toBe(x.high, `s=${s}, x.low=${x.low}, x.high=${x.high}, y.low=${y.low}, y.high=${y.high}, base=${base}`);
    }
    const count = 100;
    {
      const u = new Uint64(264762631, 2836123747);
      expect(u.toString(13)).toEqual('153c9125c642b111b8');
      check(u, 13);
    }

    for (let base = 2; base <= 36; ++base) {
      for (let i = 0; i < count; ++i) {
        check(Uint64.random(), base);
      }
    }
  });
开发者ID:google,项目名称:neuroglancer,代码行数:20,代码来源:uint64.spec.ts

示例4: check

 function check(x: Uint64, base: number) {
   let s = x.toString(base);
   let y = Uint64.parseString(s, base);
   expect(y.low).toBe(x.low);
   expect(y.high).toBe(x.high);
 }
开发者ID:janelia-flyem,项目名称:neuroglancer,代码行数:6,代码来源:uint64.spec.ts

示例5: it

  it('test', () => {
    let ht = new HashTable();
    let map = new Map();

    let maxValue = Math.pow(2, 32);
    function genNumber() { return Math.floor(Math.random() * maxValue); }
    function getRandomKey() {
      while (true) {
        let v = new Uint64(genNumber(), genNumber());
        if (v.low !== ht.emptyLow || v.high !== ht.emptyHigh) {
          return v;
        }
      }
    }

    function compareViaIterate() {
      let htValues = new Map();
      for (let [low, high] of ht) {
        let v = new Uint64(low, high);
        let s = v.toString();
        if (htValues.has(s)) {
          throw new Error('Duplicate key in hash table: ' + [low, high]);
        }
        if (!map.has(s)) {
          throw new Error('Unexpected key ' + [low, high] + ' in hash table');
        }
        htValues.set(s, v);
      }
      for (let [s, k] of map) {
        if (!htValues.has(s)) {
          throw new Error('Hash table is missing key ' + [k.low, k.high]);
        }
      }
    }

    function compareViaHas() {
      for (let [, k] of map) {
        expect(ht.has(k.low, k.high)).toBe(true, `Hash table is missing key ${[k.low, k.high]}`);
      }
    }

    function compare() {
      compareViaIterate();
      compareViaHas();
    }
    let numInsertions = 100;
    for (let i = 0; i < numInsertions; ++i) {
      let k: Uint64;
      let s: string;
      while (true) {
        k = getRandomKey();
        s = k.toString();
        if (!map.has(k)) {
          break;
        }
      }
      map.set(s, k);
      expect(ht.has(k.low, k.high))
          .toBe(false, `Unexpected positive has result for ${[k.low, k.high]}`);
      ht.add(k.low, k.high);
      compare();
    }
  });
开发者ID:funkey,项目名称:neuroglancer,代码行数:63,代码来源:hash_table.spec.ts

示例6: check

 function check(x: Uint64, base: number) {
   let s = x.toString(base);
   let y = Uint64.parseString(s, base);
   expect(y.low).toBe(x.low, `s=${s}, x.low=${x.low}, x.high=${x.high}, y.low=${y.low}, y.high=${y.high}, base=${base}`);
   expect(y.high).toBe(x.high, `s=${s}, x.low=${x.low}, x.high=${x.high}, y.low=${y.low}, y.high=${y.high}, base=${base}`);
 }
开发者ID:google,项目名称:neuroglancer,代码行数:6,代码来源:uint64.spec.ts


注:本文中的neuroglancer/util/uint64.Uint64.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。