本文整理汇总了TypeScript中Immutable.Map类的典型用法代码示例。如果您正苦于以下问题:TypeScript Map类的具体用法?TypeScript Map怎么用?TypeScript Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Map类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: stations
export function stations(state:Map<string,any> = Map<string,any>(), action:any):Map<string, List<StationModel>> {
function indexOfStation(businessId, stationId):any {
return stations.findIndex((i:StationModel) => {
return i.getKey('businessId') === businessId && i.getKey('id') == stationId;
});
}
switch (action.type) {
case StationsAction.RECEIVE_STATIONS:
return state.update(action.source, (value) => action.stations);
case StationsAction.RECEIVE_STATIONS_GEO:
for (var i in action.payload) {
var station = action.payload[i];
var source = station.source;
var stations:List<StationModel> = state.get(source);
stations = stations.update(indexOfStation(station.businessId, station.id), (i_station:StationModel) => {
return i_station.setKey<StationModel>(StationModel, 'geoLocation', {
lat: station.lat,
lon: station.lon,
city: station.city,
country: station.country
})
});
state = state.setIn([source], stations);
}
return state;
default:
return state;
}
}
开发者ID:Floodlight-Studios,项目名称:studioDashboard,代码行数:32,代码来源:StationsReducer.ts
示例2: referencedModels
export function referencedModels(
project: Project,
mod: Module,
all?: Map<string, ModelDef>,
): Map<string, ModelDef> {
if (!all) {
all = Map();
}
const mdl = defined(project.model(mod.modelName));
const name = mdl.ident;
if (all.has(name)) {
const def = defined(all.get(name)).update('modules', (modules: Set<Module>) =>
modules.add(mod),
);
all = all.set(name, def);
} else {
all = all.set(
name,
new ModelDef({
model: mdl,
modules: Set<Module>([mod]),
}),
);
}
for (const [name, module] of mdl.modules) {
all = referencedModels(project, module, all);
}
return all;
}
开发者ID:bpowers,项目名称:sd.js,代码行数:29,代码来源:vars.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: appdb
export default function appdb(state:Map<string, any> = Map<string, any>({}), action:any):Map<string, any> {
switch (action.type) {
case StationsAction.RECEIVE_TOTAL_STATIONS:
return state.merge({
totalStations: {time: Date.now(), totalStations: action.totalStations}
});
case AppdbAction.AUTH_FAIL:
case AppdbAction.AUTH_PASS:
return state.merge({
credentials: {
authenticated: action.authenticated,
user: action.user,
pass: action.pass,
remember: action.remember,
reason: action.reason
},
appBaseUrlUser: `${baseUrl}?resellerUserName=${action.user}&resellerPassword=${action.pass}`
});
case AppdbAction.APP_INIT:
return state.merge({
appStartTime: Date.now(),
appBaseUrl: `${baseUrl}`
});
case AppdbAction.CLOUD_SERVERS:
return state.merge({
cloudServers: action.payload
});
case AppdbAction.SERVERS_STATUS:
return state.merge({serversStatus: action.payload});
default:
return state;
}
}
开发者ID:Floodlight-Studios,项目名称:studioDashboard,代码行数:33,代码来源:AppdbReducer.ts
示例5: reducer
function reducer(state: IReduxState = initial, { type, payload }: IAction): IReduxState {
const imState: Map<string, any> = fromJS(state);
switch (type) {
case 'VIEW_POLLS:LOAD_POLLS_SUCCESS':
return imState.set('polls', payload).toJS();
case 'VIEW_POLLS:LOAD_POLL_SUCCESS': {
interface IData { results: IPollResult[]; poll: IPoll; }
const data = payload as IData;
return imState.set('selectedPoll', data).toJS();
}
case 'VIEW_POLLS:SELECT_ANSWER': {
interface IData { questionIndex: number; answerIndex: number; }
const data = payload as IData;
const questions = imState.getIn(['selectedPoll', 'poll', 'questions']);
const question = questions.get(data.questionIndex);
return imState.setIn(
['selectedPoll', 'poll', 'questions', data.questionIndex],
question.set('answers', question.get('answers').map(
(answer: Map<string, any>, index: number) => answer.set('isSelected', index === data.answerIndex),
)),
).toJS();
}
default: return state;
}
}
开发者ID:sigrlami,项目名称:pollock,代码行数:26,代码来源:reducer.ts
示例6: 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
示例7: 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
示例8:
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
示例9: binary
binary(n: ast.BinaryExpr): string {
// exponentiation isn't a builtin operator in JS, it
// is implemented as a function in the Math module.
if (n.op === '^') {
const l = n.l.walk(this);
const r = n.r.walk(this);
return `Math.pow(${l}, ${r})`;
} else if (n.op === '=' && n.l instanceof ast.Constant && isNaN(n.l.value)) {
const r = n.r.walk(this);
return `isNaN(${r})`;
} else if (n.op === '=' && n.r instanceof ast.Constant && isNaN(n.r.value)) {
const l = n.r.walk(this);
return `isNaN(${l})`;
}
let op = n.op;
// only need to convert some of them
if (JsOps.has(n.op)) {
op = defined(JsOps.get(n.op));
}
const l = n.l.walk(this);
const r = n.r.walk(this);
return `${l} ${op} ${r}`;
}
开发者ID:bpowers,项目名称:sd.js,代码行数:25,代码来源:vars.ts
示例10: Graph
addNode(node: any) {
var nodes = this.nodes.push(node);
var children = this.children.set(node.id, List<any>());
var parents = this.parents.set(node.id, List<any>());
return new Graph(nodes, children, parents);
}
开发者ID:gsanta,项目名称:gsgraph,代码行数:7,代码来源:Graph.ts
注:本文中的Immutable.Map类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论