Commit graph

17 commits

Author SHA1 Message Date
Sam Atkins edc3ed2a0e AK: Allow creating NonnullPtrVectors from an initializer list
This was present in Vector already. Clang-format fixed some const
positions automatically too.

Also removed a now-ambiguous and unnecessary constructor from Shell.
2022-09-08 18:53:08 +02:00
Andreas Kling 83082b12b7 LibWeb: Make reverse iterators work for const NonnullPtrVectors 2022-04-13 19:52:25 +02:00
kleines Filmröllchen ff8ca811c7 AK: Add find_first_index to NonnullPtrVector that strips smart pointer
When we want to use the find_first_index that base Vector provides, we
need to provide an element of the real contained type. That's impossible
for OwnPtr, however, and even with RefPtr there might be instances where
we have a raw reference to the object we want to find, but no smart
pointer. Therefore, overloading this function (with an identical body,
the magic is done by the find_index templatization) with `T const&` as a
parameter allows there use cases.
2022-04-06 12:47:50 +02:00
Idan Horowitz 086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Andreas Kling fc6b7fcd97 AK: Add const variant of Vector::in_reverse() 2022-03-18 15:18:48 +01:00
Federico Guerinoni 0aed2f0f86 AK: Add reverse iterator as member 2022-03-09 17:16:28 +01:00
Federico Guerinoni a54e20d958 AK: Implement ReverseIterator for NonnullPtrVector 2022-03-09 17:16:28 +01:00
Brian Gianforcaro c192c303d2 AK: Use default constructor/destructor instead of declaring an empty one
Default implementations allow for more optimizations.
See: https://pvs-studio.com/en/docs/warnings/v832/
2021-09-16 17:17:13 +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
Andreas Kling 81c6d8e98e AK: Make Nonnull*PtrVector use size_t for indexes
This was weird. It turns out these class were using int indexes and
sizes despite being derived from Vector which uses size_t.

Make the universe right again by using size_t here as well.
2021-02-20 18:34:32 +01:00
Andreas Kling dd43cf2657 AK: Use ALWAYS_INLINE all over NonnullPtrVector
I saw NonnullOwnPtrVector::at() in a profile and that was silly, as we
should definitely be inlining it.
2020-11-23 14:08:50 +01:00
Lenny Maiorani f5ced347e6 AK: Prefer using instead of typedef
Problem:
- `typedef` is a keyword which comes from C and carries with it old
  syntax that is hard to read.
- Creating type aliases with the `using` keyword allows for easier
  future maintenance because it supports template syntax.
- There is inconsistent use of `typedef` vs `using`.

Solution:
- Use `clang-tidy`'s checker called `modernize-use-using` to update
  the syntax to use the newer syntax.
- Remove unused functions to make `clang-tidy` happy.
- This results in consistency within the codebase.
2020-11-12 10:19:04 +01:00
asynts 1b3ecb01a5 AK: Add generic SimpleIterator class to replace VectorIterator. 2020-09-08 14:01:21 +02:00
Andreas Kling 94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling a5cdd0afa5 NonnullPtrVector: Add ptr_at() getters for accessing the NonnullPtr
Normally you want to access the T&, but sometimes you need to grab at
the NonnullPtr, for example when moving it out of the Vector before
a call to remove(). This is generally a weird pattern, but I don't have
a better solution at the moment.
2019-08-19 19:04:52 +02:00
Andreas Kling 6a5446d6dd AK: Simplify NonnullPtrVector template a bit.
Add an "ElementType" typedef to NonnullOwnPtr and NonnullRefPtr to allow
clients to easily find the pointee type. Then use this to remove a template
argument from NonnullPtrVector. :^)
2019-07-25 11:10:28 +02:00
Andreas Kling 10d120dc85 AK: Share code between NonnullOwnPtrVector and NonnullRefPtrVector.
These can just inherit from a shared base template. Thanks to Robin for the
sweet idea :^)
2019-07-25 11:00:26 +02:00