Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
gfx::Range Class Reference

#include <range.h>

Public Member Functions

constexpr Range ()
 
constexpr Range (uint32_t start, uint32_t end)
 
constexpr Range (uint32_t position)
 
constexpr bool IsValid () const
 
constexpr uint32_t start () const
 
void set_start (uint32_t start)
 
constexpr uint32_t end () const
 
void set_end (uint32_t end)
 
constexpr uint32_t length () const
 
constexpr bool is_reversed () const
 
constexpr bool is_empty () const
 
constexpr uint32_t GetMin () const
 
constexpr uint32_t GetMax () const
 
constexpr bool operator== (const Range &other) const
 
constexpr bool operator!= (const Range &other) const
 
constexpr bool EqualsIgnoringDirection (const Range &other) const
 
constexpr bool Intersects (const Range &range) const
 
constexpr bool Contains (const Range &range) const
 
constexpr bool IsBoundedBy (const Range &range) const
 
constexpr Range Intersect (const Range &range) const
 
std::string ToString () const
 

Static Public Member Functions

static constexpr Range InvalidRange ()
 

Detailed Description

Definition at line 33 of file range.h.

Constructor & Destructor Documentation

◆ Range() [1/3]

constexpr gfx::Range::Range ( )
inlineconstexpr

Definition at line 36 of file range.h.

36: Range(0) {}
constexpr Range()
Definition range.h:36

◆ Range() [2/3]

constexpr gfx::Range::Range ( uint32_t  start,
uint32_t  end 
)
inlineconstexpr

Definition at line 39 of file range.h.

39: start_(start), end_(end) {}
constexpr uint32_t end() const
Definition range.h:59
constexpr uint32_t start() const
Definition range.h:56

◆ Range() [3/3]

constexpr gfx::Range::Range ( uint32_t  position)
inlineexplicitconstexpr

Definition at line 42 of file range.h.

42: Range(position, position) {}

Member Function Documentation

◆ Contains()

constexpr bool gfx::Range::Contains ( const Range range) const
inlineconstexpr

Definition at line 84 of file range.h.

84 {
85 return range.IsBoundedBy(*this) &&
86 // A non-empty range doesn't contain the range [max, max).
87 (range.GetMax() != GetMax() || range.is_empty() == is_empty());
88 }
constexpr uint32_t GetMax() const
Definition range.h:70
constexpr bool is_empty() const
Definition range.h:66

◆ end()

constexpr uint32_t gfx::Range::end ( ) const
inlineconstexpr

Definition at line 59 of file range.h.

59{ return end_; }

◆ EqualsIgnoringDirection()

constexpr bool gfx::Range::EqualsIgnoringDirection ( const Range other) const
inlineconstexpr

Definition at line 76 of file range.h.

76 {
77 return GetMin() == other.GetMin() && GetMax() == other.GetMax();
78 }
constexpr uint32_t GetMin() const
Definition range.h:69

◆ GetMax()

constexpr uint32_t gfx::Range::GetMax ( ) const
inlineconstexpr

Definition at line 70 of file range.h.

70{ return start() > end() ? start() : end(); }

◆ GetMin()

constexpr uint32_t gfx::Range::GetMin ( ) const
inlineconstexpr

Definition at line 69 of file range.h.

69{ return start() < end() ? start() : end(); }

◆ Intersect()

constexpr Range gfx::Range::Intersect ( const Range range) const
inlineconstexpr

Definition at line 99 of file range.h.

99 {
100 const uint32_t min = std::max(GetMin(), range.GetMin());
101 const uint32_t max = std::min(GetMax(), range.GetMax());
102 return (min < max || Contains(range) || range.Contains(*this)) ? Range(min, max)
103 : InvalidRange();
104 }
constexpr bool Contains(const Range &range) const
Definition range.h:84
static constexpr Range InvalidRange()
Definition range.h:50
static float max(float r, float g, float b)
Definition hsl.cpp:49
static float min(float r, float g, float b)
Definition hsl.cpp:48

◆ Intersects()

constexpr bool gfx::Range::Intersects ( const Range range) const
inlineconstexpr

Definition at line 81 of file range.h.

81{ return Intersect(range).IsValid(); }
constexpr Range Intersect(const Range &range) const
Definition range.h:99
constexpr bool IsValid() const
Definition range.h:53

◆ InvalidRange()

static constexpr Range gfx::Range::InvalidRange ( )
inlinestaticconstexpr

Definition at line 50 of file range.h.

50{ return Range(std::numeric_limits<uint32_t>::max()); }

◆ is_empty()

constexpr bool gfx::Range::is_empty ( ) const
inlineconstexpr

Definition at line 66 of file range.h.

66{ return start() == end(); }

◆ is_reversed()

constexpr bool gfx::Range::is_reversed ( ) const
inlineconstexpr

Definition at line 65 of file range.h.

65{ return start() > end(); }

◆ IsBoundedBy()

constexpr bool gfx::Range::IsBoundedBy ( const Range range) const
inlineconstexpr

Definition at line 92 of file range.h.

92 {
93 return IsValid() && range.IsValid() && GetMin() >= range.GetMin() && GetMax() <= range.GetMax();
94 }

◆ IsValid()

constexpr bool gfx::Range::IsValid ( ) const
inlineconstexpr

Definition at line 53 of file range.h.

53{ return *this != InvalidRange(); }

◆ length()

constexpr uint32_t gfx::Range::length ( ) const
inlineconstexpr

Definition at line 63 of file range.h.

63{ return GetMax() - GetMin(); }

◆ operator!=()

constexpr bool gfx::Range::operator!= ( const Range other) const
inlineconstexpr

Definition at line 75 of file range.h.

75{ return !(*this == other); }

◆ operator==()

constexpr bool gfx::Range::operator== ( const Range other) const
inlineconstexpr

Definition at line 72 of file range.h.

72 {
73 return start() == other.start() && end() == other.end();
74 }

◆ set_end()

void gfx::Range::set_end ( uint32_t  end)
inline

Definition at line 60 of file range.h.

60{ end_ = end; }

◆ set_start()

void gfx::Range::set_start ( uint32_t  start)
inline

Definition at line 57 of file range.h.

57{ start_ = start; }

◆ start()

constexpr uint32_t gfx::Range::start ( ) const
inlineconstexpr

Definition at line 56 of file range.h.

56{ return start_; }

◆ ToString()

std::string gfx::Range::ToString ( ) const

Definition at line 14 of file range.cc.

14 {
15 return base::StringPrintf("{%" PRIu32 ",%" PRIu32 "}", start(), end());
16}
std::string StringPrintf(const std::string &format, Args... args)

The documentation for this class was generated from the following files: