yeet
This commit is contained in:
14
node_modules/react-native/Libraries/FBLazyVector/BUCK
generated
vendored
Normal file
14
node_modules/react-native/Libraries/FBLazyVector/BUCK
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
load("//tools/build_defs/oss:rn_defs.bzl", "fb_apple_library")
|
||||
|
||||
fb_apple_library(
|
||||
name = "FBLazyVector",
|
||||
autoglob = True,
|
||||
complete_nullability = True,
|
||||
contacts = ["oncall+react_native@xmail.facebook.com"],
|
||||
enable_exceptions = False,
|
||||
extension_api_only = True,
|
||||
frameworks = [],
|
||||
labels = ["supermodule:ios/default/public.react_native.infra"],
|
||||
link_whole = False,
|
||||
visibility = ["PUBLIC"],
|
||||
)
|
31
node_modules/react-native/Libraries/FBLazyVector/FBLazyVector.podspec
generated
vendored
Normal file
31
node_modules/react-native/Libraries/FBLazyVector/FBLazyVector.podspec
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
require "json"
|
||||
|
||||
package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
|
||||
version = package['version']
|
||||
|
||||
source = { :git => 'https://github.com/facebook/react-native.git' }
|
||||
if version == '1000.0.0'
|
||||
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
|
||||
source[:commit] = `git rev-parse HEAD`.strip
|
||||
else
|
||||
source[:tag] = "v#{version}"
|
||||
end
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "FBLazyVector"
|
||||
s.version = version
|
||||
s.summary = "-" # TODO
|
||||
s.homepage = "https://reactnative.dev/"
|
||||
s.license = package["license"]
|
||||
s.author = "Facebook, Inc. and its affiliates"
|
||||
s.platforms = { :ios => "10.0", :tvos => "10.0" }
|
||||
s.source = source
|
||||
s.source_files = "**/*.{c,h,m,mm,cpp}"
|
||||
s.header_dir = "FBLazyVector"
|
||||
|
||||
end
|
130
node_modules/react-native/Libraries/FBLazyVector/FBLazyVector/FBLazyIterator.h
generated
vendored
Normal file
130
node_modules/react-native/Libraries/FBLazyVector/FBLazyVector/FBLazyIterator.h
generated
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <functional>
|
||||
#import <iterator>
|
||||
|
||||
namespace FB {
|
||||
|
||||
template <typename T, typename U>
|
||||
class LazyIterator {
|
||||
public:
|
||||
using value_type = T;
|
||||
using pointer = std::unique_ptr<T>;
|
||||
using reference = T;
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
using difference_type = std::int32_t;
|
||||
using size_type = std::int32_t;
|
||||
using convert_type = std::function<T(U)>;
|
||||
|
||||
public:
|
||||
LazyIterator() = default;
|
||||
|
||||
LazyIterator(U vector, convert_type convert, size_type i)
|
||||
: _v(vector), _i(i), _convert(std::move(convert)) {}
|
||||
|
||||
bool operator==(const LazyIterator &other) const {
|
||||
return _i == other._i && _v == other._v;
|
||||
}
|
||||
|
||||
bool operator<(const LazyIterator &b) const {
|
||||
return _i < b._i;
|
||||
}
|
||||
|
||||
value_type operator*() const {
|
||||
return _convert(_v[_i]);
|
||||
}
|
||||
|
||||
std::unique_ptr<value_type> operator->() const {
|
||||
return std::make_unique<value_type>(*this);
|
||||
}
|
||||
|
||||
LazyIterator operator+(difference_type n) const {
|
||||
return LazyIterator(_v, _convert, _i + n);
|
||||
}
|
||||
|
||||
LazyIterator &operator+=(difference_type n) {
|
||||
_i += n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LazyIterator &operator-=(difference_type n) {
|
||||
_i -= n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LazyIterator operator-(difference_type n) const {
|
||||
return LazyIterator(_v, _i - n);
|
||||
}
|
||||
|
||||
difference_type operator-(const LazyIterator &a) const {
|
||||
return _i - a._i;
|
||||
}
|
||||
|
||||
LazyIterator &operator++() {
|
||||
return *this += 1;
|
||||
}
|
||||
|
||||
LazyIterator operator++(int) {
|
||||
auto tmp = *this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
LazyIterator &operator--() {
|
||||
return *this -= 1;
|
||||
}
|
||||
|
||||
LazyIterator operator--(int) {
|
||||
auto tmp = *this;
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
value_type operator[](difference_type n) const {
|
||||
return _convert(_v[_i + n]);
|
||||
}
|
||||
|
||||
private:
|
||||
U _v;
|
||||
size_type _i;
|
||||
convert_type _convert;
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
LazyIterator<T, U> operator+(typename LazyIterator<T, U>::difference_type n,
|
||||
const LazyIterator<T, U> &i) {
|
||||
return i + n;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator!=(const LazyIterator<T, U> &a,
|
||||
const LazyIterator<T, U> &b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator<=(const LazyIterator<T, U> &a,
|
||||
const LazyIterator<T, U> &b) {
|
||||
return a < b || a == b;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator>(const LazyIterator<T, U> &a,
|
||||
const LazyIterator<T, U> &b) {
|
||||
return b < a;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator>=(const LazyIterator<T, U> &a,
|
||||
const LazyIterator<T, U> &b) {
|
||||
return a > b || a == b;
|
||||
}
|
||||
|
||||
}
|
99
node_modules/react-native/Libraries/FBLazyVector/FBLazyVector/FBLazyVector.h
generated
vendored
Normal file
99
node_modules/react-native/Libraries/FBLazyVector/FBLazyVector/FBLazyVector.h
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <cassert>
|
||||
#import <functional>
|
||||
#import <iterator>
|
||||
|
||||
#import <FBLazyVector/FBLazyIterator.h>
|
||||
|
||||
namespace FB {
|
||||
|
||||
/**
|
||||
* Presents a type-safe wrapper around an arbitrary object that represents an _immutable_ array of objects.
|
||||
* Each item is constructed lazily on demand and reconstructed on each access; there is no caching.
|
||||
*/
|
||||
template <typename T, typename U>
|
||||
class LazyVector {
|
||||
public:
|
||||
using value_type = T;
|
||||
using reference = T;
|
||||
using const_reference = T;
|
||||
using const_iterator = LazyIterator<T, U>;
|
||||
using iterator = const_iterator;
|
||||
using size_type = std::int32_t;
|
||||
using convert_type = std::function<T(U)>;
|
||||
|
||||
static LazyVector<T, U> fromUnsafeRawValue(U v, size_type size, convert_type convert) {
|
||||
return {v, size, convert};
|
||||
}
|
||||
|
||||
U unsafeRawValue() const {
|
||||
return _v;
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return _size == 0;
|
||||
}
|
||||
|
||||
size_type size() const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
const_reference at(size_type pos) const {
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (!(pos < _size)) throw std::out_of_range("out of range");
|
||||
#else
|
||||
assert(pos < _size || !"out of range");
|
||||
#endif
|
||||
return _convert(_v[pos]);
|
||||
}
|
||||
|
||||
const_reference operator[](size_type pos) const {
|
||||
assert(pos < _size);
|
||||
return _convert(_v[pos]);
|
||||
}
|
||||
|
||||
const_reference front() const {
|
||||
assert(_size);
|
||||
return (*this)[0];
|
||||
}
|
||||
|
||||
const_reference back() const {
|
||||
assert(_size);
|
||||
return (*this)[_size - 1];
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return const_iterator(_v, _convert, 0);
|
||||
}
|
||||
|
||||
const_iterator cbegin() const {
|
||||
return begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(_v, _convert, _size);
|
||||
}
|
||||
|
||||
const_iterator cend() const {
|
||||
return end();
|
||||
}
|
||||
|
||||
private:
|
||||
/** Wrapped vector */
|
||||
LazyVector(U vector, size_type size, convert_type convert)
|
||||
: _v(vector), _size(size), _convert(convert) {}
|
||||
|
||||
U _v;
|
||||
size_type _size;
|
||||
convert_type _convert;
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user