sorted_ifyer/
lib.rs

1/*
2Copyright 2025 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
3
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License. */
15   
16/// Returns true if potentialy_sorted_stuff is sorted
17/// bahavour with NaN or negative 0 or infinity is not defined
18/// Maximum is the highest number to sort, usefull in bubblesort
19/// Maximum must not be higher than potentialy_sorted_stuff.len()
20/// Recursiveness is how inefficent it is with 0 being the most efficent.
21/// Inefficency increases ((recursiveness)*2) once recursiveness >=1 asumming all other variables are the same
22pub fn is_sorted<T: std::cmp::PartialOrd>(
23    potentialy_sorted_stuff: &[T], maximum: usize, recursiveness: u128,
24    version: u128
25) -> bool {
26    assert!(
27        version == 0 || version == 254 || version == 255,
28        "883842 version not supported, version == {version}"
29    );
30    assert_eq!(recursiveness, 0, "74118115 recursiveness is currently not supported");
31    for i in 1..maximum {
32        if potentialy_sorted_stuff[i - 1] > potentialy_sorted_stuff[i] {
33            return false;
34        }
35    }
36    true
37}