本文整理汇总了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];
}
}
}
示例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
}
示例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
);
}
示例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
}
示例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)
}
})
示例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)
}
示例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;
}
示例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);
}
示例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));
}
示例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
}