Skip to content

Commit

Permalink
[cps] [subway] LineId and StationId as string
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Aug 24, 2024
1 parent 85220c5 commit b8b4133
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
5 changes: 2 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -22,7 +22,6 @@
然后删除非 normal 的 path,所谓 normal path,
即,没有在一条 line 上下车上车的现象的 path。


# later

[cps] 也许用深圳的地铁作为例子,并且写一个模仿《百度地图》的前端出来试试。
Expand Down
32 changes: 16 additions & 16 deletions src/cps/subway/Subway.ts
Original file line number Diff line number Diff line change
@@ -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<StationId>
}

export type Station = {
id: StationId
lines: Set<LineId>
position: Position
}

export type Subway = {
name: string,
lineMap: Map<
Line,
{
stations: Array<Station>
}
>
stationMap: Map<
Station,
{
lines: Set<Line>
position: Position
}
>
name: string
lineMap: Map<LineId, Line>
stationMap: Map<StationId, Station>
}

export function createSubway(name: string): Subway {
Expand Down
2 changes: 1 addition & 1 deletion src/cps/subway/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./Subway.js"
export * from "./defineLine.js"

Check failure on line 1 in src/cps/subway/index.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Cannot find module './defineLine.js' or its corresponding type declarations.

Check failure on line 1 in src/cps/subway/index.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

Cannot find module './defineLine.js' or its corresponding type declarations.
export * from "./defineStation.js"

Check failure on line 2 in src/cps/subway/index.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Cannot find module './defineStation.js' or its corresponding type declarations.

Check failure on line 2 in src/cps/subway/index.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

Cannot find module './defineStation.js' or its corresponding type declarations.
export * from "./Subway.js"

0 comments on commit b8b4133

Please sign in to comment.