From b8b41332c8640f075da4d2f84db55e6d6120979e Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Sat, 24 Aug 2024 21:31:09 +0800 Subject: [PATCH] [cps] [subway] `LineId` and `StationId` as `string` --- TODO.md | 5 ++--- src/cps/subway/Subway.ts | 32 ++++++++++++++++---------------- src/cps/subway/index.ts | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/TODO.md b/TODO.md index cb08132..f1ea820 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,7 @@ -[cps] [subway] `defineLine` -- take a ordered list of stations - [cps] [subway] `defineStation` +[cps] [subway] `defineLine` -- take a ordered list of stations + [cps] [subway] define `bostonSubway` [cps] [problem-space] [subway] `SubwayProblemSpace` & `createSubwayProblemSpace` @@ -22,7 +22,6 @@ 然后删除非 normal 的 path,所谓 normal path, 即,没有在一条 line 上下车上车的现象的 path。 - # later [cps] 也许用深圳的地铁作为例子,并且写一个模仿《百度地图》的前端出来试试。 diff --git a/src/cps/subway/Subway.ts b/src/cps/subway/Subway.ts index 6627b2c..8c1a886 100644 --- a/src/cps/subway/Subway.ts +++ b/src/cps/subway/Subway.ts @@ -1,23 +1,23 @@ -export type Line = string -export type Station = string +export type LineId = string +export type StationId = string + export type Position = string +export type Line = { + id: LineId + stations: Array +} + +export type Station = { + id: StationId + lines: Set + position: Position +} export type Subway = { - name: string, - lineMap: Map< - Line, - { - stations: Array - } - > - stationMap: Map< - Station, - { - lines: Set - position: Position - } - > + name: string + lineMap: Map + stationMap: Map } export function createSubway(name: string): Subway { diff --git a/src/cps/subway/index.ts b/src/cps/subway/index.ts index 92440c5..772ca78 100644 --- a/src/cps/subway/index.ts +++ b/src/cps/subway/index.ts @@ -1,3 +1,3 @@ -export * from "./Subway.js" export * from "./defineLine.js" export * from "./defineStation.js" +export * from "./Subway.js"