• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

TypeScript collection.Map类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中angular2/src/facade/collection.Map的典型用法代码示例。如果您正苦于以下问题:TypeScript Map类的具体用法?TypeScript Map怎么用?TypeScript Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: coalesce

export function coalesce(records: ProtoRecord[]): ProtoRecord[] {
  var res: List<ProtoRecord> = [];
  var indexMap: Map<number, number> = new Map<number, number>();

  for (var i = 0; i < records.length; ++i) {
    var r = records[i];
    var record = _replaceIndices(r, res.length + 1, indexMap);
    var matchingRecord = _findMatching(record, res);

    if (isPresent(matchingRecord) && record.lastInBinding) {
      res.push(_selfRecord(record, matchingRecord.selfIndex, res.length + 1));
      indexMap.set(r.selfIndex, matchingRecord.selfIndex);
      matchingRecord.referencedBySelf = true;

    } else if (isPresent(matchingRecord) && !record.lastInBinding) {
      if (record.argumentToPureFunction) {
        matchingRecord.argumentToPureFunction = true;
      }

      indexMap.set(r.selfIndex, matchingRecord.selfIndex);

    } else {
      res.push(record);
      indexMap.set(r.selfIndex, record.selfIndex);
    }
  }

  return res;
}
开发者ID:goderbauer,项目名称:angular,代码行数:29,代码来源:coalesce.ts


示例2: create

  static create({id, selector, compileChildren, events, host, properties, readAttributes, type,
                 callOnDestroy, callOnChange, callOnCheck, callOnInit, callOnAllChangesDone,
                 changeDetection, exportAs}: {
    id?: string,
    selector?: string,
    compileChildren?: boolean,
    events?: List<string>,
    host?: Map<string, string>,
    properties?: List<string>,
    readAttributes?: List<string>,
    type?: number,
    callOnDestroy?: boolean,
    callOnChange?: boolean,
    callOnCheck?: boolean,
    callOnInit?: boolean,
    callOnAllChangesDone?: boolean,
    changeDetection?: string,
    exportAs?: string
  }) {
    let hostListeners = new Map();
    let hostProperties = new Map();
    let hostAttributes = new Map();
    let hostActions = new Map();

    if (isPresent(host)) {
      MapWrapper.forEach(host, (value: string, key: string) => {
        var matches = RegExpWrapper.firstMatch(hostRegExp, key);
        if (isBlank(matches)) {
          hostAttributes.set(key, value);
        } else if (isPresent(matches[1])) {
          hostProperties.set(matches[1], value);
        } else if (isPresent(matches[2])) {
          hostListeners.set(matches[2], value);
        } else if (isPresent(matches[3])) {
          hostActions.set(matches[3], value);
        }
      });
    }

    return new DirectiveMetadata({
      id: id,
      selector: selector,
      compileChildren: compileChildren,
      events: events,
      hostListeners: hostListeners,
      hostProperties: hostProperties,
      hostAttributes: hostAttributes,
      hostActions: hostActions,
      properties: properties,
      readAttributes: readAttributes,
      type: type,
      callOnDestroy: callOnDestroy,
      callOnChange: callOnChange,
      callOnCheck: callOnCheck,
      callOnInit: callOnInit,
      callOnAllChangesDone: callOnAllChangesDone,
      changeDetection: changeDetection,
      exportAs: exportAs
    });
  }
开发者ID:Salim-K,项目名称:angular,代码行数:60,代码来源:api.ts


示例3: resolve

  /**
   * Returns the {@link View} for a component:
   * - Set the {@link View} to the overridden view when it exists or fallback to the default
   * `TemplateResolver`,
   *   see `setView`.
   * - Override the directives, see `overrideViewDirective`.
   * - Override the @View definition, see `setInlineTemplate`.
   *
   * @param component
   * @returns {ViewDefinition}
   */
  resolve(component: Type): View {
    var view = this._viewCache.get(component);
    if (isPresent(view)) return view;

    view = this._views.get(component);
    if (isBlank(view)) {
      view = super.resolve(component);
    }

    var directives = view.directives;
    var overrides = this._directiveOverrides.get(component);

    if (isPresent(overrides) && isPresent(directives)) {
      directives = ListWrapper.clone(view.directives);
      MapWrapper.forEach(overrides, (to, from) => {
        var srcIndex = directives.indexOf(from);
        if (srcIndex == -1) {
          throw new BaseException(
              `Overriden directive ${stringify(from)} not found in the template of ${stringify(component)}`);
        }
        directives[srcIndex] = to;
      });
      view = new View(
          {template: view.template, templateUrl: view.templateUrl, directives: directives});
    }

    var inlineTemplate = this._inlineTemplates.get(component);
    if (isPresent(inlineTemplate)) {
      view = new View({template: inlineTemplate, templateUrl: null, directives: view.directives});
    }

    this._viewCache.set(component, view);
    return view;
  }
开发者ID:Salim-K,项目名称:angular,代码行数:45,代码来源:template_resolver_mock.ts


示例4: config

  /**
   * Given a component and a configuration object, add the route to this registry
   */
  config(parentComponent, config: StringMap<string, any>): void {
    assertValidConfig(config);

    var recognizer: RouteRecognizer = this._rules.get(parentComponent);

    if (isBlank(recognizer)) {
      recognizer = new RouteRecognizer();
      this._rules.set(parentComponent, recognizer);
    }

    if (StringMapWrapper.contains(config, 'redirectTo')) {
      recognizer.addRedirect(config['path'], config['redirectTo']);
      return;
    }

    config = StringMapWrapper.merge(
        config, {'component': normalizeComponentDeclaration(config['component'])});

    var component = config['component'];
    var terminal = recognizer.addConfig(config['path'], config, config['as']);

    if (component['type'] == 'constructor') {
      if (terminal) {
        assertTerminalComponent(component['constructor'], config['path']);
      } else {
        this.configFromComponent(component['constructor']);
      }
    }
  }
开发者ID:Salim-K,项目名称:angular,代码行数:32,代码来源:route_registry.ts


示例5: coalesce

export function coalesce(srcRecords: ProtoRecord[]): ProtoRecord[] {
  let dstRecords = [];
  let excludedIdxs = [];
  let indexMap: Map<number, number> = new Map<number, number>();
  let skipDepth = 0;
  let skipSources: ProtoRecord[] = ListWrapper.createFixedSize(srcRecords.length);

  for (let protoIndex = 0; protoIndex < srcRecords.length; protoIndex++) {
    let skipRecord = skipSources[protoIndex];
    if (isPresent(skipRecord)) {
      skipDepth--;
      skipRecord.fixedArgs[0] = dstRecords.length;
    }

    let src = srcRecords[protoIndex];
    let dst = _cloneAndUpdateIndexes(src, dstRecords, indexMap);

    if (dst.isSkipRecord()) {
      dstRecords.push(dst);
      skipDepth++;
      skipSources[dst.fixedArgs[0]] = dst;
    } else {
      let record = _mayBeAddRecord(dst, dstRecords, excludedIdxs, skipDepth > 0);
      indexMap.set(src.selfIndex, record.selfIndex);
    }
  }

  return _optimizeSkips(dstRecords);
}
开发者ID:0oAimZo0,项目名称:Angular2Learning,代码行数:29,代码来源:coalesce.ts


示例6: method

 method(name: string): MethodFn {
   if (this._methods.has(name)) {
     return this._methods.get(name);
   } else {
     return this.reflectionCapabilities.method(name);
   }
 }
开发者ID:Salim-K,项目名称:angular,代码行数:7,代码来源:reflector.ts


示例7: setter

 setter(name: string): SetterFn {
   if (this._setters.has(name)) {
     return this._setters.get(name);
   } else {
     return this.reflectionCapabilities.setter(name);
   }
 }
开发者ID:Salim-K,项目名称:angular,代码行数:7,代码来源:reflector.ts


示例8: isPresent

 annotations(typeOrFunc: /*Type*/ any): List<any> {
   if (this._injectableInfo.has(typeOrFunc)) {
     var res = this._injectableInfo.get(typeOrFunc)._annotations;
     return isPresent(res) ? res : [];
   } else {
     return this.reflectionCapabilities.annotations(typeOrFunc);
   }
 }
开发者ID:goderbauer,项目名称:angular,代码行数:8,代码来源:reflector.ts


示例9: viewCreated

 viewCreated(view: AppView) {
   var viewId = _nextId++;
   _allViewsById.set(viewId, view);
   _allIdsByView.set(view, viewId);
   for (var i = 0; i < view.elementRefs.length; i++) {
     _setElementId(this._renderer.getNativeElementSync(view.elementRefs[i]), [viewId, i]);
   }
 }
开发者ID:cedriclam,项目名称:angular,代码行数:8,代码来源:debug_element_view_listener.ts


示例10: getComponentId

export function getComponentId(componentStringId: string) {
  var id = _componentUIDs.get(componentStringId);
  if (isBlank(id)) {
    id = _nextComponentUID++;
    _componentUIDs.set(componentStringId, id);
  }
  return id;
}
开发者ID:Salim-K,项目名称:angular,代码行数:8,代码来源:util.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript collection.MapWrapper类代码示例发布时间:2022-05-25
下一篇:
TypeScript collection.ListWrapper类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap