objc2_gameplay_kit/generated/GKQuadtree.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8extern_class!(
9 /// The individual node(s) that make up a GKQuadtree.
10 /// Used as a hint for faster removal via [GKQuadtree removeData:WithNode:]
11 ///
12 /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkquadtreenode?language=objc)
13 #[unsafe(super(NSObject))]
14 #[derive(Debug, PartialEq, Eq, Hash)]
15 pub struct GKQuadtreeNode;
16);
17
18extern_conformance!(
19 unsafe impl NSObjectProtocol for GKQuadtreeNode {}
20);
21
22impl GKQuadtreeNode {
23 extern_methods!();
24}
25
26/// Methods declared on superclass `NSObject`.
27impl GKQuadtreeNode {
28 extern_methods!(
29 #[unsafe(method(init))]
30 #[unsafe(method_family = init)]
31 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
32
33 #[unsafe(method(new))]
34 #[unsafe(method_family = new)]
35 pub unsafe fn new() -> Retained<Self>;
36 );
37}
38
39extern_class!(
40 /// A tree data structure where each level has 4 children that subdivide a given space into the four quadrants.
41 /// Stores arbitrary NSObject data via points and quads.
42 ///
43 /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkquadtree?language=objc)
44 #[unsafe(super(NSObject))]
45 #[derive(Debug, PartialEq, Eq, Hash)]
46 pub struct GKQuadtree<ElementType: ?Sized = AnyObject>;
47);
48
49impl<ElementType: ?Sized + Message + AsRef<NSObject>> GKQuadtree<ElementType> {
50 /// Unchecked conversion of the generic parameter.
51 ///
52 /// # Safety
53 ///
54 /// The generic must be valid to reinterpret as the given type.
55 #[inline]
56 pub unsafe fn cast_unchecked<NewElementType: ?Sized + Message + AsRef<NSObject>>(
57 &self,
58 ) -> &GKQuadtree<NewElementType> {
59 unsafe { &*((self as *const Self).cast()) }
60 }
61}
62
63extern_conformance!(
64 unsafe impl<ElementType: ?Sized + AsRef<NSObject>> NSObjectProtocol for GKQuadtree<ElementType> {}
65);
66
67impl<ElementType: Message + AsRef<NSObject>> GKQuadtree<ElementType> {
68 extern_methods!(
69 /// Removes the given NSObject from this quad tree.
70 /// Note that this is an exhaustive search and is slow.
71 /// Cache the relevant GKQuadTreeNode and use removeElement:WithNode: for better performance.
72 ///
73 ///
74 /// Parameter `element`: the data to be removed
75 ///
76 /// Returns: returns YES if the data was removed, NO otherwise
77 #[unsafe(method(removeElement:))]
78 #[unsafe(method_family = none)]
79 pub unsafe fn removeElement(&self, element: &ElementType) -> bool;
80
81 /// Removes the given NSObject from the given quadtree node
82 /// Note that this is not an exhaustive search and is faster than removeData:
83 ///
84 ///
85 /// Parameter `data`: the data to be removed
86 ///
87 /// Parameter `node`: the node in which this data resides
88 ///
89 /// Returns: returns YES if the data was removed, NO otherwise
90 #[unsafe(method(removeElement:withNode:))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn removeElement_withNode(
93 &self,
94 data: &ElementType,
95 node: &GKQuadtreeNode,
96 ) -> bool;
97 );
98}
99
100/// Methods declared on superclass `NSObject`.
101impl<ElementType: Message + AsRef<NSObject>> GKQuadtree<ElementType> {
102 extern_methods!(
103 #[unsafe(method(init))]
104 #[unsafe(method_family = init)]
105 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
106
107 #[unsafe(method(new))]
108 #[unsafe(method_family = new)]
109 pub unsafe fn new() -> Retained<Self>;
110 );
111}