Skip to content

Commit

Permalink
Rename nodesCount to nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed Jan 11, 2025
1 parent 1e82f19 commit c5f5f84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example/lib/src/feature/quadtree/quadtree_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class QuadTreePainter extends RePainterBase {
..write(' | ')
..write('Nodes:')
..write(nbsp)
..write(_quadTree.nodesCount);
..write(_quadTree.nodes);
_textPainter
..text = TextSpan(
text: status.toString(),
Expand Down
8 changes: 4 additions & 4 deletions lib/src/collisions/quadtree.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ final class QuadTree {
Uint32List _recycledNodes;

/// Number of active objects in the QuadTree.
int get nodesCount => _nodesCount - _recycledNodesCount;
int get nodes => _nodesCount - _recycledNodesCount;

/// List of nodes in the QuadTree.
/// Each index in the list is the identifier of the node.
Expand Down Expand Up @@ -969,8 +969,8 @@ final class QuadTree {
});

// Check if all nodes are visited
if (nodesCount != nodeIds.length)
errors.add('Invalid nodes count: $nodesCount != ${nodeIds.length}.');
if (nodes != nodeIds.length)
errors.add('Invalid nodes count: $nodes != ${nodeIds.length}.');

return errors;
}
Expand All @@ -981,7 +981,7 @@ final class QuadTree {

@override
String toString() => 'QuadTree{'
'nodes: $nodesCount, '
'nodes: $nodes, '
'objects: $length'
'}';
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/quadtree_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ void main() => group('Quadtree', () {
capacity: 6,
);
expect(qt.length, equals(0));
expect(qt.nodesCount, equals(0));
expect(qt.nodes, equals(0));
for (var i = 0; i < 10; i++) {
expect(
() => qt.insert(ui.Rect.fromLTWH(i * 10.0, i * 10.0, 10, 10)),
returnsNormally,
);
}
expect(qt.length, equals(10));
expect(qt.nodesCount, greaterThan(0));
expect(qt.nodes, greaterThan(0));
expect(() => qt.get(10), returnsNormally);
expect(
qt.get(10),
Expand Down

0 comments on commit c5f5f84

Please sign in to comment.