Eine aufbereitete Darstellung der Quelle
Stufen
Anforderungen
|
Konzepte
|
Entwurf
|
Entwicklung
|
Qualitätssicherung
|
Lebenszyklus
|
Steuerung
Ziele
Untersuchung
mit Columbo
Integrität von
Datenbanken
Interaktion und
Portierbarkeit
Ergonomie der
Schnittstellen
Angebot
Produkte
Projekt
Beratung
Mittel
Analytik
Modellierung
Sprachen
Algebra
Logik
Hardware
Denken
Kreativität
Zusammenhänge
Gesellschaft
Wirtschaft
Branche
Firma
Benutzer
products
/
Sources
/
formale Sprachen
/
C
/
Firefox
/
devtools
/
client
/
themes
/
images
/ (
Firefox Browser
Version 153.0.1
©
) Datei vom 27.6.2026 mit Größe 487 B
Bilddatei
scoped_arena_containers.h
products/Sources/formale Sprachen/C/Android/art/art/libartbase/base/scoped_arena_containers.h
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ART_LIBARTBASE_BASE_SCOPED_ARENA_CONTAINERS_H_ #define ART_LIBARTBASE_BASE_SCOPED_ARENA_CONTAINERS_H_ #include
#include
#include
#include
#include
#include
#include
#include
#include "arena_containers.h" // For ArenaAllocatorAdapterKind. #include "dchecked_vector.h" #include "hash_map.h" #include "hash_set.h" #include "safe_map.h" #include "scoped_arena_allocator.h" namespace art { // Adapter for use of ScopedArenaAllocator in STL containers. // Use ScopedArenaAllocator::Adapter() to create an adapter to pass to container constructors. // For example, // void foo(ScopedArenaAllocator* allocator) { // ScopedArenaVector
foo_vector(allocator->Adapter(kArenaAllocMisc)); // ScopedArenaSafeMap
foo_map(std::less
(), allocator->Adapter()); // // Use foo_vector and foo_map... // } template
class ScopedArenaAllocatorAdapter; template
using ScopedArenaDeque = std::deque
>; template
using ScopedArenaForwardList = std::forward_list
>; template
using ScopedArenaList = std::list
>; template
using ScopedArenaQueue = std::queue
>; template
using ScopedArenaVector = dchecked_vector
>; template
> using ScopedArenaPriorityQueue = std::priority_queue
, Comparator>; template
using ScopedArenaStdStack = std::stack
>; template
> using ScopedArenaSet = std::set
>; template
> using ScopedArenaSafeMap = SafeMap
>>; template
, typename HashFn = DefaultHashFn
, typename Pred = DefaultPred
> using ScopedArenaHashSet = HashSet
>; template
, typename HashFn = DefaultHashFn
, typename Pred = DefaultPred
> using ScopedArenaHashMap = HashMap
>>; template
, class KeyEqual = std::equal_to
> using ScopedArenaUnorderedMap = std::unordered_map
>>; template
, class KeyEqual = std::equal_to
> using ScopedArenaUnorderedMultimap = std::unordered_multimap
>>; // Implementation details below. template <> class ScopedArenaAllocatorAdapter
: private DebugStackReference, private DebugStackIndirectTopRef, private ArenaAllocatorAdapterKind { public: using value_type = void; using pointer = void*; using const_pointer = const void*; template
struct rebind { using other = ScopedArenaAllocatorAdapter
; }; explicit ScopedArenaAllocatorAdapter(ScopedArenaAllocator* allocator, ArenaAllocKind kind = kArenaAllocSTL) : DebugStackReference(allocator), DebugStackIndirectTopRef(allocator), ArenaAllocatorAdapterKind(kind), arena_stack_(allocator->arena_stack_) { } template
ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter
& other) : DebugStackReference(other), DebugStackIndirectTopRef(other), ArenaAllocatorAdapterKind(other), arena_stack_(other.arena_stack_) { } ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter&) = default; ScopedArenaAllocatorAdapter& operator=(const ScopedArenaAllocatorAdapter&) = default; ~ScopedArenaAllocatorAdapter() = default; private: ArenaStack* arena_stack_; template
friend class ScopedArenaAllocatorAdapter; }; template
class ScopedArenaAllocatorAdapter : private DebugStackReference, private DebugStackIndirectTopRef, private ArenaAllocatorAdapterKind { public: using value_type = T; using pointer = T*; using reference = T&; using const_pointer = const T*; using const_reference = const T&; using size_type = size_t; using difference_type = ptrdiff_t; template
struct rebind { using other = ScopedArenaAllocatorAdapter
; }; explicit ScopedArenaAllocatorAdapter(ScopedArenaAllocator* allocator, ArenaAllocKind kind = kArenaAllocSTL) : DebugStackReference(allocator), DebugStackIndirectTopRef(allocator), ArenaAllocatorAdapterKind(kind), arena_stack_(allocator->arena_stack_) { } template
ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter
& other) : DebugStackReference(other), DebugStackIndirectTopRef(other), ArenaAllocatorAdapterKind(other), arena_stack_(other.arena_stack_) { } ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter&) = default; ScopedArenaAllocatorAdapter& operator=(const ScopedArenaAllocatorAdapter&) = default; ~ScopedArenaAllocatorAdapter() = default; size_type max_size() const { return static_cast
(-1) / sizeof(T); } pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } pointer allocate(size_type n, [[maybe_unused]] ScopedArenaAllocatorAdapter
::pointer hint = nullptr) { DCHECK_LE(n, max_size()); DebugStackIndirectTopRef::CheckTop(); return reinterpret_cast
(arena_stack_->Alloc(n * sizeof(T), ArenaAllocatorAdapterKind::Kind())); } void deallocate(pointer p, size_type n) { DebugStackIndirectTopRef::CheckTop(); arena_stack_->MakeInaccessible(p, sizeof(T) * n); } template
void construct(U* p, Args&&... args) { // Don't CheckTop(), allow reusing existing capacity of a vector/deque below the top. ::new (static_cast
(p)) U(std::forward
(args)...); } template
void destroy(U* p) { // Don't CheckTop(), allow reusing existing capacity of a vector/deque below the top. p->~U(); } private: ArenaStack* arena_stack_; template
friend class ScopedArenaAllocatorAdapter; template
friend bool operator==(const ScopedArenaAllocatorAdapter
& lhs, const ScopedArenaAllocatorAdapter
& rhs); }; template
inline bool operator==(const ScopedArenaAllocatorAdapter
& lhs, const ScopedArenaAllocatorAdapter
& rhs) { return lhs.arena_stack_ == rhs.arena_stack_; } template
inline bool operator!=(const ScopedArenaAllocatorAdapter
& lhs, const ScopedArenaAllocatorAdapter
& rhs) { return !(lhs == rhs); } inline ScopedArenaAllocatorAdapter
ScopedArenaAllocator::Adapter(ArenaAllocKind kind) { return ScopedArenaAllocatorAdapter
(this, kind); } } // namespace art #endif // ART_LIBARTBASE_BASE_SCOPED_ARENA_CONTAINERS_H_
2026-10-10
Neuigkeiten
Aktuelles
Motto des Tages
Open Source Software
Quellcodebibliothek
Eigene Quellcodes
Fremde Quellcodes
Suchen
Jenseits des Üblichen ....
Besucherstatistik
Statistik
#Sources=1126438
#Domains=1897691
Impressum
|
Ethik und Gesetz
|
Haftungsausschluß
|
Kontakt
|
Seitenstruktur
|
©
2026 JDD
|