@@ -564,7 +564,7 @@ where
564
564
565
565
/// Gets the number of vertices in the graph.
566
566
pub fn vertex_count ( & self ) -> usize {
567
- self . as_storage_of :: < Vertex < _ > > ( ) . len ( )
567
+ self . core . vertices . len ( )
568
568
}
569
569
570
570
/// Gets an immutable view of the vertex with the given key.
@@ -580,7 +580,8 @@ where
580
580
// TODO: Return `Clone + Iterator`.
581
581
/// Gets an iterator of immutable views over the vertices in the graph.
582
582
pub fn vertices ( & self ) -> impl Iterator < Item = VertexView < & Self > > {
583
- self . as_storage_of :: < Vertex < _ > > ( )
583
+ self . core
584
+ . vertices
584
585
. iter ( )
585
586
. map ( |( key, _) | key)
586
587
. map ( move |key| View :: bind_unchecked ( self , key) )
@@ -589,15 +590,16 @@ where
589
590
590
591
/// Gets an iterator of orphan views over the vertices in the graph.
591
592
pub fn vertex_orphans ( & mut self ) -> impl Iterator < Item = VertexOrphan < G > > {
592
- self . as_storage_mut_of :: < Vertex < _ > > ( )
593
+ self . core
594
+ . vertices
593
595
. iter_mut ( )
594
596
. map ( |( key, data) | Orphan :: bind_unchecked ( data, key) )
595
597
. map ( From :: from)
596
598
}
597
599
598
600
/// Gets the number of arcs in the graph.
599
601
pub fn arc_count ( & self ) -> usize {
600
- self . as_storage_of :: < Arc < _ > > ( ) . len ( )
602
+ self . core . arcs . len ( )
601
603
}
602
604
603
605
/// Gets an immutable view of the arc with the given key.
@@ -613,7 +615,8 @@ where
613
615
// TODO: Return `Clone + Iterator`.
614
616
/// Gets an iterator of immutable views over the arcs in the graph.
615
617
pub fn arcs ( & self ) -> impl Iterator < Item = ArcView < & Self > > {
616
- self . as_storage_of :: < Arc < _ > > ( )
618
+ self . core
619
+ . arcs
617
620
. iter ( )
618
621
. map ( |( key, _) | key)
619
622
. map ( move |key| View :: bind_unchecked ( self , key) )
@@ -622,15 +625,16 @@ where
622
625
623
626
/// Gets an iterator of orphan views over the arcs in the graph.
624
627
pub fn arc_orphans ( & mut self ) -> impl Iterator < Item = ArcOrphan < G > > {
625
- self . as_storage_mut_of :: < Arc < _ > > ( )
628
+ self . core
629
+ . arcs
626
630
. iter_mut ( )
627
631
. map ( |( key, data) | Orphan :: bind_unchecked ( data, key) )
628
632
. map ( From :: from)
629
633
}
630
634
631
635
/// Gets the number of edges in the graph.
632
636
pub fn edge_count ( & self ) -> usize {
633
- self . as_storage_of :: < Edge < _ > > ( ) . len ( )
637
+ self . core . edges . len ( )
634
638
}
635
639
636
640
/// Gets an immutable view of the edge with the given key.
@@ -646,7 +650,8 @@ where
646
650
// TODO: Return `Clone + Iterator`.
647
651
/// Gets an iterator of immutable views over the edges in the graph.
648
652
pub fn edges ( & self ) -> impl Iterator < Item = EdgeView < & Self > > {
649
- self . as_storage_of :: < Edge < _ > > ( )
653
+ self . core
654
+ . edges
650
655
. iter ( )
651
656
. map ( |( key, _) | key)
652
657
. map ( move |key| View :: bind_unchecked ( self , key) )
@@ -655,15 +660,16 @@ where
655
660
656
661
/// Gets an iterator of orphan views over the edges in the graph.
657
662
pub fn edge_orphans ( & mut self ) -> impl Iterator < Item = EdgeOrphan < G > > {
658
- self . as_storage_mut_of :: < Edge < _ > > ( )
663
+ self . core
664
+ . edges
659
665
. iter_mut ( )
660
666
. map ( |( key, data) | Orphan :: bind_unchecked ( data, key) )
661
667
. map ( From :: from)
662
668
}
663
669
664
670
/// Gets the number of faces in the graph.
665
671
pub fn face_count ( & self ) -> usize {
666
- self . as_storage_of :: < Face < _ > > ( ) . len ( )
672
+ self . core . faces . len ( )
667
673
}
668
674
669
675
/// Gets an immutable view of the face with the given key.
@@ -679,7 +685,8 @@ where
679
685
// TODO: Return `Clone + Iterator`.
680
686
/// Gets an iterator of immutable views over the faces in the graph.
681
687
pub fn faces ( & self ) -> impl Iterator < Item = FaceView < & Self > > {
682
- self . as_storage_of :: < Face < _ > > ( )
688
+ self . core
689
+ . faces
683
690
. iter ( )
684
691
. map ( |( key, _) | key)
685
692
. map ( move |key| View :: bind_unchecked ( self , key) )
@@ -688,7 +695,8 @@ where
688
695
689
696
/// Gets an iterator of orphan views over the faces in the graph.
690
697
pub fn face_orphans ( & mut self ) -> impl Iterator < Item = FaceOrphan < G > > {
691
- self . as_storage_mut_of :: < Face < _ > > ( )
698
+ self . core
699
+ . faces
692
700
. iter_mut ( )
693
701
. map ( |( key, data) | Orphan :: bind_unchecked ( data, key) )
694
702
. map ( From :: from)
@@ -746,7 +754,8 @@ where
746
754
// better than using `FaceView::triangulate` until triangulation
747
755
// is reworked.
748
756
let keys = self
749
- . as_storage_of :: < Face < _ > > ( )
757
+ . core
758
+ . faces
750
759
. iter ( )
751
760
. map ( |( key, _) | key)
752
761
. collect :: < Vec < _ > > ( ) ;
@@ -890,7 +899,8 @@ where
890
899
/// ```
891
900
pub fn disjoint_subgraph_vertices ( & self ) -> impl ExactSizeIterator < Item = VertexView < & Self > > {
892
901
let keys = self
893
- . as_storage_of :: < Vertex < _ > > ( )
902
+ . core
903
+ . vertices
894
904
. iter ( )
895
905
. map ( |( key, _) | key)
896
906
. collect :: < HashSet < _ > > ( ) ;
@@ -909,6 +919,15 @@ where
909
919
unimplemented ! ( )
910
920
}
911
921
922
+ /// Shrinks the capacity of the graph's underlying storage as much as
923
+ /// possible.
924
+ pub fn shrink_to_fit ( & mut self ) {
925
+ self . core . vertices . shrink_to_fit ( ) ;
926
+ self . core . arcs . shrink_to_fit ( ) ;
927
+ self . core . edges . shrink_to_fit ( ) ;
928
+ self . core . faces . shrink_to_fit ( ) ;
929
+ }
930
+
912
931
/// Creates a [`Buildable`] mesh data structure from the graph.
913
932
///
914
933
/// The output is created from each unique vertex in the graph. No face data
0 commit comments