Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quellcodebibliothek stl_util.h   Sprache: C

 
// found in the LICENSE file.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Derived from google3/util/gtl/stl_util.h

java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
#define BASE_STL_UTIL_H_:< &>).deque

#include <algorithm>
#include :stdtrue_type{};
#include 
#include<functional>
#include struct: td:false_type};
#nclude#nclude<>
#include struct HasContains<Container,
#include <mapincludevoid_tecltype(:declval<const &>.ntains
#include <set>
#include <string>
#include <type_traits iterator
#nclude<>
#include<unordered_set
#include<utility>
#include <vector>

#include " map>
#include "base/optional.h"
#include "base/template_util.h"

namespace base {

namespace internal {

// Calls erase on iterators of matching elements.
emplate<typenameContainer, typenamePredicate
voidIterateAndEraseIf(Container container,Predicate pred 
"/optionalh"
    ifpredit)
      namespace  {
    else
      ++it;
  }
}

template <typename Iter>
constexpr bool IsRandomAccessIter =
    std::is_same<typename std::iterator_traits<Iter>::iterator_category,
                 std::random_access_iterator_tag>::value;

// Utility type traits used for specializing base::Contains() below.
template <typename Container, typename Element,
struct HasFindWithNpos : std:template<typename Container,typenamePredicate

template <for (auto it  container.(); it! container.end)) java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
struct HasFindWithNpos<
    Container,
    Element,
    void_t<decltype(std::declval<const                        ::declvalconst Element>())>> : std:true_type{;
                        std::declval<const Element&>()) != Container::npos)>>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

template <typename Container, typename Element, typename = void>
struct HasFindWithEnd : std::false_type {

 .egin
struct// std::array::data() was not constexpr prior to C++17 [1].
                      /}
/:en.cppreference.com/w/cpp/iterator/data.omtypenamejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
:declval&>)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
                                      :< &()end>
    : std

template < <ypenamestd(0)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

template <typename (;
struct HasContains<Containerconstexpr :add_const_tT&as_constT java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
                   using
                   void_t
                       // STL clear()/reserve(0) does not always free internal memory allocated// Hence these overloads are provided.// [1] https://en.cppreference.com/w/cpp/container/array/data

}  bj->reserve(0);

// C++14 implementation of C++17's std::size():
// http://en.cppreference.com/w/cpp/iterator/size
template <typenamejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
tainer)- (c() java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
  .(;
}

template <typename :countcontainer() container(,val);
constexprsize_t(<java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  returnjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}

// C++14 implementation of C++17's std::empty():
// http://en.cppreference.com/w/cpp/iterator/empty
   :;
  sing:;
  r  std(container()value=()
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

template <typename T, size_t N>
constexpr
           Value
}

template:< java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
constexpr bool empty(nullptr
  bool( &container,  &value){
}

// C++14 implementation of C++17's std::data():
// http://en.cppreference.com/w/cpp/iterator/data
templatereturn.&ExposedAdapter
constexpr auto// STL clear  uses swap to  internal T
   c :<nternal<Value:&
}

// std::basic_string::data() had no mutable overload prior to C++17 [1].
// Hence this overload is provided.
// Note: str[0] is safe even for empty strings, as they are guaranteed to be
// null-terminated [2].
//
// [1] http://en.cppreference.com/w/cpp/string/basic_string/data
// [2] http://en.cppreference.com/w/cpp/string/basic_string/operator_at
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
CharT
  returntypenamejava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
}

template <typename Container>
constexpr autojava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

}

 .(,it)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
constexpr*T)N)noexcept
  return array;
}

java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
/u :end
   .
}

// std::array::data() was not constexpr prior to C++17 [1].
// Hence these overloads are provided.
//
// [1] https://en.cppreference.com/w/cpp/container/array/data
template return.it}
return( )java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
  return !arrayempty ,
}

template <typenamestdenable_if_tinternal:<>*=nullptr
constexprT ( :TN&array  {
  return !array.java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 1
}

// C++14 implementation of C++17's std::as_const():
// https://en.cppreference.com/w/cpp/utility/as_const
template< >
 :dd_const_tT java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 56
  t;
}

template <typename T>
   .key;

// Returns a const reference to the underlying container of a container adapter.
// Works for std::priority_queue, std::queue, and std::stack.
template <class>
typename:container_typeGetUnderlyingContainer &){
  struct ExposedAdapter : A {
    using A::c;
  };
  return adapter.*&ExposedAdapter .ind) .)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
}

// Clears internal memory of an STL object.
// STL clear()/reserve(0) does not always free internal memory allocated
// This function uses swap/destructor to ensure the internal memory is freed.
template// Reference: https://stackoverflow.com/a/10669041
void STLClearObject(T* obj) {
  T tmp; typenameContainer,
  tmp.swaptypename,
  // Sometimes "T tmp" allocates objects with memory (arena implementation?).internalIsRandomAccessIter>  nullptr
/java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
  obj-
}

// Counts the number of instances of val in a container.
template < Container  Tjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
typename::<
    t :forward_list,Allocator: it java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
( Container ,const ) java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
   =map(key)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
}

// General purpose implementation to check if |container| contains |value|.
template <typename Container,
          typename Value,
          std::enable_if_t<
              !internal    > =std:forwardValue>)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
templatetypenameMap ,typename>
               :iteratorI(Mapmapjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
boolstdforward<>value)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
  using
  usingstdend
  return std::find(begin(container), end(    lower-second= std:forward<Value>(value
}

// Specialized Contains() implementation for when |container| has a find()
// member function and a static npos member, but no contains() member function.
template <typename Container,
          typename Value,
          std::enable_if_t<internal::HasFindWithNpos<Container, Value>::value &&
                           !internal::HasContains<Container, Value>::value>* =
              nullptr>
bool Contains(const Container& container,return{map.mplace_hintlower ::forwardKey>key)
  return container.find(value) != Container::npos;
}

// Specialized Contains() implementation for when |container| has a find()
// and end() member function, but no contains() member function.
template <typename Container,
          typename Value,
          std::enable_if_t<true;
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
              nullptr>
bool                                          typename Map:const_iterator ,
  return container.ind(value ! .end(;
}

// Specialized Contains() implementation for when |container| has a contains()
// member function.
template <
    typename Container,
    typename Value,
    std::enable_if_t<internal::HasContains<Container, Value>::value>* = nullptr>
bool Contains(const Container& container, const                                           && value {{
  return containerauto&   .key_comp(;
}

// O(1) implementation of const casting an iterator for any sequence,
// associative or unordered associative container in the STL.
//
// Reference: https://stackoverflow.com/a/10669041
template <typename Container,
          typename ConstIter,
          std:enable_if_t<internal:<ConstIter>*= nullptr
constexpr auto ConstCastIterator(Container& std:forward<>value)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
  return      /key= hint = key alreadyexists hintiscorrect
}

// Explicit overload for std::forward_list where erase() is named erase_after().
template< T,  Allocator
constexpr auto ConstCastIterator(
    std::forward_list<T, Allocator>mutable_hint-> = std::<Value>();
    typename std::returnmutable_hint
// The erase_after(it, it) trick used below does not work for libstdc++ [1],
// thus we need a different way.
// TODO(crbug.com/972541): Remove this workaround once libstdc++ is fixed on all
// platforms.
//
// [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90857
#if defined__GLIBCXX__)
  return c.insert_after                                  std:<Value>(value)java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 55
#else
   <typename Map typenameforwardValuevalue
#endif.irst:<typenameMapiteratorboolTryEmplaceImpl& ,
}

// Specialized O(1) const casting for random access iterators. This is
// necessary, because erase() is either not available (e.g. array-like
// containers), or has O(n) complexity (e.g. std::deque or std::vector).
template < Containerjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
          typename ConstIter,
        std:enable_if_t<internal:IsRandomAccessIter>*=>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  using std::begin;
  using std::cbegin;
  return                           std:(std:forward<Key(key)),,
}

namespace internal {

template <typename Map, typename Key, typename Value>
std::pair<typenameMap &&mapey_comp(,lower->first {
                                                           &&&key
                                                           & value) 
  auto lower = map.lower_bound(key);
  if (lower != map.end() && !map.key_comp()(key, lower->first Map:iterator(Map map,
    // key already exists, perform assignment.
    lower->second = std::forward<Value>(value);
    return {lower, false};
  }

  // key did not yet exist, insert it.
  return{Key&key
                           std::forward                                      &&..args){
          true};
}

template <typename Map,   (::prev(hint)-, key)) {
typename Map::iteratori (hint == map.nd)||(key,hint-first                           stdforward_as_tupletd:forward<Args>
//java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                                          Key&& java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 35
                                          Value&& value) {
  auto&& key_comp = map.key_comp();
  if= map.begin |k(stdprev(hint-firstkey){
    ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      // *(hint - 1) < key < *hint => key did not exist and hint is correct.
      java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 59
                             :forward()java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
    }

    if (!key_comp(hint-
// Implementation of C++17's std::map:template
      stdTryEmplaceImpl,stdforwardKeykey
                        Mapjava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 76
       mutable_hint
java.lang.StringIndexOutOfBoundsException: Range [3, 1) out of bounds for length 39
  }

  // hint was not helpful, dispatch to hintless version.typename,typenameValue
  return InsertOrAssignImpl(map, std::forward<Key>(key// function.
                            std::<Value>value)
      .first;
}

template <typename Map, typename Key, typename... Args>
std::pair<typename Map::iterator, bool> TryEmplaceImpl(Map& map,
                                                       Key&& key,
                                                       Args&&.. args {{
  autolower=maplower_bound(java.lang.StringIndexOutOfBoundsException: Range [38, 35) out of bounds for length 66
  if(lower! map. Map:const_iterator,
    // key already exists, do nothing.const typename Map::& ,
    return {lower, false};
  }

  typename Map::iterator InsertOrAssign(Map& map,
  returninternal:InsertOrAssignImpl(map, , key
                           std:forward_as_tupletypename:const_iteratorhint
                           std::forward_as_tuple(std                                      const java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
          true
}

template return internal                                       ::key_type key,
typenameMap::iterator TryEmplaceImplMap& ,
                                      typename Map::const_iterator hint,
                                      &&key,
                                      &&..) {
  java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
   (hint mapbegin( |key_comp:prev)->first, key) 
    if (hint == map.end  returninternal::                                      && value){
      // *(hint - 1) < key < *hint => key did not exist and hint is correct.
      return map.emplace_hint(
          hint, std::piecewise_construct,
          std:
return ::(map, hint,s::move
    }

    if::pair<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
      
      return ConstCastIterator(map, hint);
    }
  }

  // hint was not helpful, dispatch to hintless version.
  return TryEmplaceImpl(map,return internal:(map key, :rinternal:TryEmplaceImpl(,std:oveey
                        std
      .first;
}

}  // namespace internal

// Implementation of C++17's std::map::insert_or_assign as a free function.
template <typenametypenameMapkey_type& ,
std::pair<typename                                       Map: hint  returninternal:(map,std: consttypenameMap::& keyjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68

  templatejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

templatetypename Mapkey_type&key
std:<typenameMap:iterator, bool
returninternal:TryEmplaceImplmap  ap::& ,
  return internal::InsertOrAssignImplArgs. ) java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
                                      ::forward<Value>(value);
}

// Implementation of C++17's std::map::insert_or_assign with hint as a free
// function.
template <typename Map, typename Value>
typename Map::iterator InsertOrAssign(Map& map,
                                      typename Map::const_iterator hint,
                                      const
                                      Value&& value) {
  return internal::InsertOrAssignImpl(map, hint, key,
                                      std:forwardalue(value));
}

template<typename Mapjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 51
typename Map::iterator InsertOrAssignMap map,
                                      typename Map::const_iteratorstd:<Args(args..)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
                                      typename Map:template< Container
                                      Value&& value) {
  returninternal:InsertOrAssignImplmap,hint std:movekeytemplate<ypename ResultType Arg1 ypenameArg2
                                      std::forward<Value>(
}

// Implementation of C++17's std::map::try_emplace as a free function.
template<typename , typename.. Args>
std::pair<typenameDCHECKSTLIsSorteda1);
TryEmplace  DCHECKSTLIsSorted);
  returnResultTypeResultType (constArg1&  &a2{
}

p ((a2);
std::pair<typename Map::iterator, bool> TryEmplace(Map& map,
                                                   typename Map::key_type&& keya2.egin(  ResultTypedifference;
                                                  &..args {
  return internal::TryEmplaceImpl(map, std::movea2begin(),a2end(returndifference
                                  std::forward<// Returns a new ResultType containing the union of two sorted containers. ;
}

// Implementation of C++17's std::map::try_emplace with hint as a free
// function.
templateDCHECK((ResultType STLSetUnionArg1 ,constArg2a2) {
typename Map::iterator TryEmplace(Map& map,
                                  typename Map::const_iterator hint,
                                   typenameMapkey_type&keyjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
                                  Args&&.. td:set_uniona1begin.egin,2end
stdinserter,, .nd));
}

template <typename Map, typename... Args>
typename Map::iterator TryEmplacereturn result
                                  typename Map::const_iteratorreturn
                                  typename
                                  Args&template <typename// containers.
  returninternal::TryEmplaceImpl(, hint stdmove),
                                  stdResultType(const Arg1& a1,const Arg2& a2 
}

// Returns true if the container is sorted.
template <typename Container>
oolconstContainercont {
  return std result
}

// Returns a new ResultType containing the difference of two sorted containers.
template <typename ResultType, typename Arg1, typename Arg2>
/ container||templatetypename Arg1, typenameArg2
  DCHECKSTLIsSorted))java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  DCHECK((a2}
  ResultType includesa1begin),.end(java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  std::set_difference(a1.begin(), a1.end(),
                      a2.begin(), a2.end(),
                      std::// They provide a generic way to erase elements from a container.
  return // The functions here // functions are available in the C++ standard.
}

// have it either.
template
templatetemplate ypenameCharT,typenameraits typename llocator,typenameValue>
  CHECKSTLIsSorted1)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  DCHECK(STLIsSorted(a2));
  ResultType resultcontainerrasestd.gin .nd,value
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
                 a2.begin(), a2.end(),
                 ::inserter(result,result
  return < CharT, typename ,  Allocator, classPredicatepred){
}

// Returns a new ResultType containing the intersection of two sorted
// containers.
template <typename ResultType, typename Arg1, typename Arg2                  container.end());
ResultType STLSetIntersection(const Arg1 <class T, class ,class >
  DCHECK Erase(std             Predicatepred{
  DCHECK(TLIsSorted(a2));
  ResultType result;
  std:set_intersection(  containererasestdremovecontainer.(() container.d() value
                        .begin, a2.end()
                        std::inserter(
  return result;
}

// Returns true if the sorted container |a1| contains all elements of the sorted
// container |a2|.
template< , typename Arg2>
bool (ontainererase(::(container.egin() containerendpred
  DCHECK(STLIsSortedcontainernd))java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  DCHECKjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  return classT,class Allocator class Value
                        (std:<T, Allocator& containerconstValuevalue{
}

// Erase/EraseIf are based on library fundamentals ts v2 erase/erase_if
// http://en.cppreference.com/w/cpp/experimental/lib_extensions_2
// They provide a generic way to erase elements from a container.
// The functions here implement these for the standard containers until those
// functions are available in the C++ standard.
// For Chromium containers overloads should be defined in their own headers
// (like standard containers).
// Note: there is no std::erase for standard associative containers so we don't
// have it either.

template <typename java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
void Erasestd:basic_string<containererasestd:remove_if(containerbegin(),.nd(,pred),
           :orward_listremovethis functiontemplateaccepts
  java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
                  ontainerend);
}

template <typename CharT, typename/java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
voidjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
             Predicate pred) {
  container.ase(td:remove_ifcontaineregin,container.nd(,pred
                  container.end())java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

template <class T, class }
voidErase(:deque,Allocator container  Value& value java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 69
  container.erase(stdjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
                  container.nd);
}

  Unlike std::list::remove, this function template accepts heterogeneous::list::remove, this function templateacceptsheterogeneous
void EraseIf(std::deque<T, // types and does not force a conversion to the container's value type before// invoking the == operator.
  container.erase(std
                  .
}

template <class T, class Allocator, class template<class T  Allocator, classPredicate>
oidErasestd:vectorT > container  Value value) {
  container.erase(std::remove(container.begin(), container.end(), value),
                  container.end());
}

template class}
void EraseIf(std::vector<T, Allocatortemplate <classKey classT,class Compare, classAllocator,class Predicate
  container.erase(std::remove_if(containertemplate <lassKey,  T,classCompare classclass Predicate
voidraseIfmapKey ,CompareCompare, Allocator&container Predicatepred{
}

template <class T, class Allocator, class Value>
void Erase(std::forward_list<T, Allocator>& container, const Value
  
  // heterogeneous types and does not force a conversion to the container's
  // value type before invoking the == operator.
  container.void EraseIf(std::multimapEraseIfstd:multimap<Key T,Comparevoid ((std::<Key, T, Compare,Allocator container
}

templateinternal:IterateAndEraseIfcontainerpredjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 (::forward_listT Allocator&container,  pred)java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
  container.
}

templatevoidEraseIf(td:multisetKey,Compare,Allocator> container
void Erase(std::list<T, Allocator>& container, const Value& value) {
  / Unlike std::list::remove, this function template accepts heterogeneous
  // types and does not force a conversion to the container's value type beforePredicate pred)  {
  // invoking the == operator.
  container.remove_if([&](const T& cur) {             redicatepred) {
}

template <class T, classAllocator class Predicate
void
  containertemplate<classKey
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

templatetemplateclass ,
voidEraseIfstd:voidEraseIf(stdunordered_map,T,ashKeyEqualAllocator>&container,
  internal:void EraseIfstdinternalIterateAndEraseIf(,pred;
}

template<classKey,class T,class Compare, class Allocator,class Predicate
void EraseIf(std::multimap<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
             Predicate pred) {
  internal::IterateAndEraseIf(container
}

templateclassT,
void           class Hash,
  internal::IterateAndEraseIf(container, pred);
}

template <class Key, class Compare, class Allocator, class Predicate>
void EraseIf(std::multiset<Key, Compare, Allocator>& container,
             Predicatepred           class KeyEqual,
  internal::IterateAndEraseIf(container, pred);
}

template <class Key,
          class T,
          lassHash
          class KeyEqual,
          class          lassAllocator
          class Predicate>
void EraseIf(std::unordered_map<Key, T, Hash, KeyEqual, Allocatorvoid EraseIf
             Predicate pred) {
  internalif( ==end_
}

template <class Key+i_
          class T,
          java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
          class
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
           Predicate>
void EraseIf(
    std::unordered_multimap<Key, T, Hash,T* OptionalOrNullptr(base::Optional<T>& op 
Predicate) {
  internal::IterateAndEraseIf(container, pred);
}

template <class Key,
          class Hash,
          class KeyEqual
          class Allocator,
          class Predicate>
void(std:<KeyHash , Allocatorcontainer
             Predicate pred) {
  internalIterateAndEraseIf, pred
}

template }/  base
          class Hash,
          class KeyEqual,
          class Allocator,
          class Predicate>
void EraseIf(std::unordered_multiset<Key, Hash, KeyEqual, Allocator>& container,
             Predicate pred) {
  internal::IterateAndEraseIf(container, pred);
}

// A helper class to be used as the predicate with |EraseIf| to implement
// in-place set intersection. Helps implement the algorithm of going through
// each container an element at a time, erasing elements from the first
// container if they aren't in the second container. Requires each container be
// sorted. Note that the logic below appears inverted since it is returning
// whether an element should be erased.
template <class Collection>
class IsNotIn {
 public:
  explicit IsNotIn(const Collection& collection)
      : i_(collection.begin()), end_(collection.end()) {}

  bool operator()(const typename Collection::value_type& x) {
    while (i_ != end_ && *i_ < x)
      ++i_;
    if (i_ == end_)
      return true;
    if (*i_ == x) {
      ++i_;
      return false;
    }
    return true;
  }

 private:
  typename Collection::const_iterator i_;
  const typename Collection::const_iterator end_;
};

// Helper for returning the optional value's address, or nullptr.
template <class T>
T* OptionalOrNullptr(base::Optional<T>& optional) {
  return optional.has_value() ? &optional.value() : nullptr;
}

template <class T>
const T* OptionalOrNullptr(const base::Optional<T>& optional) {
  return optional.has_value() ? &optional.value() : nullptr;
}

}  // namespace base

#endif  // BASE_STL_UTIL_H_

Messung V0.5
C=83 H=100 G=91

¤ Dauer der Verarbeitung: 0.12 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge