@@ -8,22 +8,69 @@ use fixedbitset::FixedBitSet;
8
8
9
9
use crate :: schedule:: set:: * ;
10
10
11
+ /// Unique identifier for a system set stored in a [`ScheduleGraph`].
12
+ ///
13
+ /// [`ScheduleGraph`]: super::ScheduleGraph
14
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
15
+ pub struct SystemNodeId (
16
+ /// Index in various arrays storing systems.
17
+ usize ,
18
+ ) ;
19
+
20
+ impl SystemNodeId {
21
+ pub ( crate ) fn new ( index : usize ) -> Self {
22
+ Self ( index)
23
+ }
24
+
25
+ pub ( crate ) fn index ( & self ) -> usize {
26
+ self . 0
27
+ }
28
+ }
29
+
30
+ /// Unique identifier for a system set stored in a [`ScheduleGraph`].
31
+ ///
32
+ /// [`ScheduleGraph`]: super::ScheduleGraph
33
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
34
+ pub struct SystemSetNodeId (
35
+ /// Index in various arrays storing system sets.
36
+ usize ,
37
+ ) ;
38
+
39
+ impl SystemSetNodeId {
40
+ pub ( crate ) fn new ( index : usize ) -> Self {
41
+ Self ( index)
42
+ }
43
+
44
+ pub ( crate ) fn index ( & self ) -> usize {
45
+ self . 0
46
+ }
47
+ }
48
+
11
49
/// Unique identifier for a system or system set stored in a [`ScheduleGraph`].
12
50
///
13
51
/// [`ScheduleGraph`]: super::ScheduleGraph
14
52
#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
15
53
pub enum NodeId {
16
54
/// Identifier for a system.
17
- System ( usize ) ,
55
+ System ( SystemNodeId ) ,
18
56
/// Identifier for a system set.
19
- Set ( usize ) ,
57
+ Set ( SystemSetNodeId ) ,
20
58
}
21
59
22
60
impl NodeId {
23
- /// Returns the internal integer value.
24
- pub ( crate ) fn index ( & self ) -> usize {
61
+ /// Unpack [`SystemNodeId`] variant.
62
+ pub fn system ( & self ) -> Option < SystemNodeId > {
63
+ match self {
64
+ NodeId :: System ( node) => Some ( * node) ,
65
+ NodeId :: Set ( _) => None ,
66
+ }
67
+ }
68
+
69
+ /// Unpack [`SystemSetNodeId`] variant.
70
+ pub fn set ( & self ) -> Option < SystemSetNodeId > {
25
71
match self {
26
- NodeId :: System ( index) | NodeId :: Set ( index) => * index,
72
+ NodeId :: System ( _) => None ,
73
+ NodeId :: Set ( node) => Some ( * node) ,
27
74
}
28
75
}
29
76
0 commit comments