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


TypeScript List.get方法代码示例

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


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

示例1: updateActivityInMention

    updateActivityInMention(kind: TimelineActivityKind, status: Tweet, from: TwitterUser): [List<Item>, number] {
        const status_id = status.id;
        const index = this.mention.findIndex(item => {
            if (item instanceof TimelineActivity) {
                return item.kind === kind && item.status.id === status_id;
            } else {
                return false;
            }
        });

        const next_focus_index =
            this.kind === 'mention' && (index === -1 || index < this.focus_index) ?
                this.nextFocusIndex(this.mention.size + 1) : this.focus_index;

        if (index === -1) {
            return [this.mention.unshift(new TimelineActivity(kind, status, [from])), next_focus_index];
        } else {
            const will_updated = this.mention.get(index);
            if (will_updated instanceof TimelineActivity) {
                const updated = will_updated.update(status, from);
                return [this.mention.delete(index).unshift(updated), next_focus_index];
            } else {
                log.error('Invalid activity for update:', will_updated);
                return [this.mention, next_focus_index];
            }
        }
    }
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:27,代码来源:timeline.ts

示例2: findVerticalCollisions

function findVerticalCollisions(timelineDuration: number, stacks: List<List<Record<Annotation>>>, stackStartIndex: number, annotations: List<Record<Annotation>>) {
  const collisions: {annotation: Record<Annotation>, index: number, annotationStackIndex: number}[] = []
  let spread = Set(annotations)
  for(let i = stackStartIndex; i < stacks.size; i++) {
    const stack = stacks.get(i)!
    const spreadList = spread.toList()
    const withInsertions = stack.concat(spreadList).sort(recordSort)
    const insertionIndices = spreadList.map(a => {
      return withInsertions.findIndex(wi => {
        return wi.get('id', null) === a.get('id', null)
      })
    })
    const hCollisions = findHorizontalCollisions(timelineDuration, withInsertions, insertionIndices, true)
    spread = spread.union(hCollisions.map(({annotation}) => annotation))
    // Get actual indices of horiz. collisions
    stack.forEach((annotation, annotationIndex) => {
      const isCollision = hCollisions.find(hColl => {
        return hColl.annotation.get('id', null) === annotation.get('id', null)
      }) !== undefined
      if(isCollision) {
        collisions.push({annotation, index: annotationIndex, annotationStackIndex: i})
      }
    })
  }
  return collisions
}
开发者ID:StudioProcess,项目名称:rvp,代码行数:26,代码来源:annotationStack.ts

示例3: getDesiredPrice

 private getDesiredPrice(): number {
   return this.integerifyCash(
     this.lines
       .get(0) // First line contains the desiredPrice
       .match(/(?:\$)(\S*)/)[1] // Match non-space characters after dollar sign
   );
 }
开发者ID:Ethan826,项目名称:tablexi-coding-challenge,代码行数:7,代码来源:parser.ts

示例4: serializeMapItemList

function serializeMapItemList(list: List<MapItem>): string[] {
  const result: string[] = []
  for (let row = 0; row < FIELD_BLOCK_SIZE; row += 1) {
    const array: string[] = []
    for (let col = 0; col < FIELD_BLOCK_SIZE; col += 1) {
      const { type, hex } = list.get(row * FIELD_BLOCK_SIZE + col)
      if (type === 'B') {
        if (hex > 0) {
          array.push('B' + hex.toString(16))
        } else {
          array.push('X')
        }
      } else if (type === 'E') {
        array.push('E')
      } else if (type === 'R') {
        array.push('R')
      } else if (type === 'S') {
        array.push('S')
      } else if (type === 'T') {
        if (hex > 0) {
          array.push('T' + hex.toString(16))
        } else {
          array.push('X')
        }
      } else if (type === 'F') {
        array.push('F')
      } else {
        array.push('X')
      }
    }
    result.push(array.map(s => s.padEnd(3)).join(''))
  }
  return result
}
开发者ID:socoolxin,项目名称:battle-city,代码行数:34,代码来源:StageConfig.ts

示例5: while

 indices.forEach(i => {
   // Collision to right
   n = 1
   nextIndex = i+n
   while(nextIndex < list.size && !isInIndices(nextIndex) && recordHasCollision(list.get(i)!, list.get(nextIndex)!, timelineDuration)) {
     collisions.push({annotation: list.get(nextIndex)!, index: nextIndex})
     nextIndex = i+(++n)
   }
   // Collision to left
   n = 1
   nextIndex = i-n
   while(nextIndex >= 0 && !isInIndices(nextIndex) && recordHasCollision(list.get(i)!, list.get(nextIndex)!, timelineDuration)) {
     collisions.push({annotation: list.get(nextIndex)!, index: nextIndex})
     nextIndex = i-(++n)
   }
 })
开发者ID:StudioProcess,项目名称:rvp,代码行数:16,代码来源:annotationStack.ts

示例6: fitOptimized

function fitOptimized(timelineDuration: number, annotationStacks: List<List<Record<Annotation>>>, annotations: List<Record<Annotation>>) {
  const fittedStacks: Array<List<Record<Annotation>>> = []
  let rest = annotations
  let stackCounter = 0
  while(rest.size > 0) {
    const stack = stackCounter < annotationStacks.size ? annotationStacks.get(stackCounter)! : List([])
    let updatedStack = stack
    const collisions = []
    const justFitted = []
    for(let j = 0; j < rest.size; j++) {
      const annotation = rest.get(j)!
      // TODO: instead of concat+sort+binarysearch, just insert sorted
      const withInsertion = updatedStack.push(annotation).sort(recordSort)
      const insertionIndex = binarySearch(withInsertion, withInsertion.size, (list, k) => {
        return list.getIn([k, 'utc_timestamp'])
      }, annotation.get('utc_timestamp', null))

      if(findHorizontalCollisions(timelineDuration, withInsertion, List([insertionIndex])).length > 0) {
        collisions.push(annotation)
      } else {
        justFitted.push(annotation)
        updatedStack = withInsertion
      }
    }
    fittedStacks.push(List(justFitted.sort(recordSort)))
    rest = List(collisions)
    stackCounter++
  }

  return List(fittedStacks)
}
开发者ID:StudioProcess,项目名称:rvp,代码行数:31,代码来源:annotationStack.ts

示例7: findFirstNonEmptyIncome

function findFirstNonEmptyIncome(incomes: List<Income>): number {
  for (let i = 0; i < incomes.size; ++i) {
    let income = incomes.get(i);
    if (income.spentForeignAmount.lessThan(income.foreignAmount)) {
      return i;
    }
  }
  return incomes.size - 1;
}
开发者ID:gaborfeher,项目名称:grantmaster,代码行数:9,代码来源:Project.ts

示例8: List

export function moveInList<T>(list: List<T>, itemIndex: number, insertPoint: number): List<T> {
  var n = list.size;
  if (itemIndex < 0 || itemIndex >= n) throw new Error('itemIndex out of range');
  if (insertPoint < 0 || insertPoint > n) throw new Error('insertPoint out of range');
  var newArray: T[] = [];
  list.forEach((value, i) => {
    if (i === insertPoint) newArray.push(list.get(itemIndex));
    if (i !== itemIndex) newArray.push(value);
  });
  if (n === insertPoint) newArray.push(list.get(itemIndex));
  return List(newArray);
}
开发者ID:fengweijp,项目名称:pivot,代码行数:12,代码来源:general.ts

示例9: focusPreviousCellEditor

function focusPreviousCellEditor(
  state: NotebookModel,
  action: actionTypes.FocusPreviousCellEditor
): RecordOf<DocumentRecordProps> {
  const cellOrder: List<CellId> = state.getIn(["notebook", "cellOrder"]);
  const curIndex = cellOrder.findIndex(
    (id: CellId) => id === action.payload.id
  );
  const nextIndex = Math.max(0, curIndex - 1);

  return state.set("editorFocused", cellOrder.get(nextIndex));
}
开发者ID:nteract,项目名称:nteract,代码行数:12,代码来源:notebook.ts

示例10: isTankCollidedWithRivers

function isTankCollidedWithRivers(rivers: List<boolean>, tankTarget: Rect, threshhold: number) {
  for (const t of IndexHelper.iter('river', tankTarget)) {
    if (rivers.get(t)) {
      const subject = IndexHelper.getRect('river', t)
      // 因为要考虑threshhold, 所以仍然要调用testCollide来判断是否相撞
      if (testCollide(subject, tankTarget, threshhold)) {
        return true
      }
    }
  }
  return false
}
开发者ID:socoolxin,项目名称:battle-city,代码行数:12,代码来源:canTankMove.ts


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