Commit graph

23 commits

Author SHA1 Message Date
Sam Atkins 892470a912 AK: Add Array::contains_slow() and ::first_index_of(), with tests :^) 2023-04-21 20:44:47 +01:00
Daniel Bertalan 0016f63547 AK: Fix Clang 16 UBSan issue with zero-length Array
The current implementation of `Array<T, 0>` has a zero-length C array as
its storage type. While this is accepted as a GNU extension, when
compiling with Clang 16, an UBSan error is raised every time an object
is accessed whose only field is a zero-length array.

This is likely a bug in Clang 16's implementation of UBSan, which has
been reported here: https://github.com/llvm/llvm-project/issues/61775
2023-03-29 21:35:53 -04:00
MacDue 63b11030f0 Everywhere: Use ReadonlySpan<T> instead of Span<T const> 2023-02-08 19:15:45 +00:00
kleines Filmröllchen 026cc3d4b9 AK: Add Span to Array conversion function 2022-12-15 00:21:00 -07:00
Linus Groh d26aabff04 Everywhere: Run clang-format 2022-12-03 23:52:23 +00:00
Andreas Kling ae3ffdd521 AK: Make it possible to not using AK classes into the global namespace
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by
default, but can be overridden by build flags.

This is a step towards integrating Jakt and AK types.
2022-11-26 15:51:34 +01:00
Sam Atkins c0ca6e470f AK+Userland: Rename Array::front/back to first/last
This is the name that is used for every other collection type so let's
be consistent.
2022-04-06 14:31:52 +02:00
Arne Elster 6a0cac7cdb AK: Array can tell its inner type
Array should be able to tell the type of the elements it contains.
2022-02-26 16:01:26 +01:00
Jelle Raaijmakers bc36e39d07 AK: Simplify Array::back() by checking for Size > 0
We do not want `Array::max()` to be used here at all - we know the
size at compile-time, after all.
2021-12-11 23:15:24 +01:00
Lenny Maiorani c27abaabc4 AK: Stop publishing detail namespaced functions
Problem:
- `AK::Detail::integer_sequence_generate_array` is published via a
  `using` directive in the `Array.h` header, but this is a `Detail`
  function.

Solution:
- Remove the `using` declaration.
2021-08-15 15:14:19 +02:00
Andreas Kling 8ea029405f AK: Sprinkle [[nodiscard]] on AK::Array 2021-07-21 18:22:10 +02:00
Andreas Kling 4b0498e38b AK: Convert Array to east-const style 2021-07-21 18:21:15 +02:00
Ali Mohammad Pur ab03c6fadf AK: Export integer_sequence_generate_array() 2021-05-05 19:02:51 +02:00
Ali Mohammad Pur b361793ad8 AK: Add min() and max() methods to Array<T, N>
...That are only defined when min() and max() are defined on the
elements.
2021-05-05 19:02:51 +02:00
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Hendiadyoin1 f673f08bec AK: Fix integer_sequence_generate_array
It was for some reason Architecture dependent.
Now we use size_t instead of unsinged long
2021-03-21 09:35:23 +01:00
Andreas Kling 69d8ad52c4 AK: Always do bounds checking in Array::operator[] 2021-02-27 09:23:32 +01:00
Andreas Kling 5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Brian Gianforcaro df73a86875 AK: Add an implementation of Array<T, Size>::fill(...) 2021-02-21 12:54:39 +01:00
AnotherTest f0d85acc94 AK: Add an iota_array() function that can generate an array
...of increasing values with an optional offset.
2021-02-08 18:08:55 +01:00
asynts 3aaece8733 AK: Remove redundant compare() functions. 2021-01-02 01:37:22 +01:00
asynts b5ca74e78a AK: Add template deduction guides for Array. 2020-09-21 20:17:36 +02:00
asynts 76e37e8c96 AK: Add Array<T, Size> template. 2020-09-08 14:01:21 +02:00