text:
SkRect Reference
===

---

struct SkRect {

    SkScalar fLeft;
    SkScalar fTop;
    SkScalar fRight;
    SkScalar fBottom;

    static constexpr SkRect MakeEmpty();
    static constexpr SkRect MakeWH(SkScalar w, SkScalar h);
    static SkRect MakeIWH(int w, int h);
    static constexpr SkRect MakeSize(const SkSize& size);
    static constexpr SkRect MakeLTRB(SkScalar l, SkScalar t, SkScalar r,
                                     SkScalar b);
    static constexpr SkRect MakeXYWH(SkScalar x, SkScalar y, SkScalar w,
                                     SkScalar h);
    static SkRect Make(const SkISize& size);
    static SkRect Make(const SkIRect& irect);
    bool isEmpty() const;
    bool isSorted() const;
    bool isFinite() const;
    SkScalar x() const;
    SkScalar y() const;
    SkScalar left() const;
    SkScalar top() const;
    SkScalar right() const;
    SkScalar bottom() const;
    SkScalar width() const;
    SkScalar height() const;
    SkScalar centerX() const;
    SkScalar centerY() const;
    friend bool operator==(const SkRect& a, const SkRect& b);
    friend bool operator!=(const SkRect& a, const SkRect& b);
    void toQuad(SkPoint quad[4]) const;
    void setEmpty();
    void set(const SkIRect& src);
    void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
    void setLTRB(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
    void iset(int left, int top, int right, int bottom);
    void isetWH(int width, int height);
    void set(const SkPoint pts[], int count);
    void setBounds(const SkPoint pts[], int count);
    bool setBoundsCheck(const SkPoint pts[], int count);
    void setBoundsNoCheck(const SkPoint pts[], int count);
    void set(const SkPoint& p0, const SkPoint& p1);
    void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height);
    void setWH(SkScalar width, SkScalar height);
    SkRect makeOffset(SkScalar dx, SkScalar dy) const;
    SkRect makeInset(SkScalar dx, SkScalar dy) const;
    SkRect makeOutset(SkScalar dx, SkScalar dy) const;
    void offset(SkScalar dx, SkScalar dy);
    void offset(const SkPoint& delta);
    void offsetTo(SkScalar newX, SkScalar newY);
    void inset(SkScalar dx, SkScalar dy);
    void outset(SkScalar dx, SkScalar dy);
    bool intersect(const SkRect& r);
    bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
    bool intersect(const SkRect& a, const SkRect& b);
    bool intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) const;
    bool intersects(const SkRect& r) const;
    static bool Intersects(const SkRect& a, const SkRect& b);
    void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
    void join(const SkRect& r);
    void joinNonEmptyArg(const SkRect& r);
    void joinPossiblyEmptyRect(const SkRect& r);
    bool contains(SkScalar x, SkScalar y) const;
    bool contains(const SkRect& r) const;
    bool contains(const SkIRect& r) const;
    void round(SkIRect* dst) const;
    void roundOut(SkIRect* dst) const;
    void roundOut(SkRect* dst) const;
    void roundIn(SkIRect* dst) const;
    SkIRect round() const;
    SkIRect roundOut() const;
    void sort();
    SkRect makeSorted() const;
    const SkScalar* asScalars() const;
    void dump(bool asHex) const;
    void dump() const;
    void dumpHex() const;
};

SkRect holds four SkScalar coordinates describing the upper and
lower bounds of a rectangle. SkRect may be created from outer bounds or
from position, width, and height. SkRect describes an area; if its right
is less than or equal to its left, or if its bottom is less than or equal to
its top, it is considered empty.

SkRect can be constructed from int values to avoid compiler warnings that
integer input cannot convert to SkScalar without loss of precision.

Type
Member
Description

    SkScalar
    fLeft

May contain any value, including infinities and NaN. The smaller of the
horizontal values when sorted. When equal to or greater than fRight, Rect is empty.

    SkScalar
    fTop

May contain any value, including infinities and NaN. The smaller of the
vertical values when sorted. When equal to or greater than fBottom, Rect is empty.

    SkScalar
    fRight

May contain any value, including infinities and NaN. The larger of the
horizontal values when sorted. When equal to or less than fLeft, Rect is empty.

    SkScalar
    fBottom

May contain any value, including infinities and NaN. The larger of the
vertical values when sorted. When equal to or less than fTop, Rect is empty.

---

static constexpr SkRect MakeEmpty()

Returns constructed SkRect set to (0, 0, 0, 0).
Many other rectangles are empty; if left is equal to or greater than right,
or if top is equal to or greater than bottom. Setting all members to zero
is a convenience, but does not designate a special empty rectangle.

### Return Value

bounds (0, 0, 0, 0)

### Example

<fiddle-embed name="2e262d0ac4b8ef51695e0525fc3ecdf6">

#### Example Output

~~~~
MakeEmpty isEmpty: true
offset rect isEmpty: true
inset rect isEmpty: true
outset rect isEmpty: false
~~~~

</fiddle-embed>

### See Also

isEmpty setEmpty SkIRect::MakeEmpty

---

static constexpr SkRect MakeWH(SkScalar w, SkScalar h)

Returns constructed SkRect set to SkScalar values (0, 0, w, h). Does not
validate input; w or h may be negative.

Passing integer values may generate a compiler warning since SkRect cannot
represent 32-bit integers exactly. Use SkIRect for an exact integer rectangle.

### Parameters

    w
    SkScalar width of constructed SkRect

    h
    SkScalar height of constructed SkRect

### Return Value

bounds (0, 0, w, h)

### Example

<fiddle-embed name="8009d30f431e01f8aea4808e9017d9bf">

#### Example Output

~~~~
all equal
~~~~

</fiddle-embed>

### See Also

MakeSize MakeXYWH MakeIWH setWH SkIRect::MakeWH

---

static SkRect MakeIWH(int w, int h)

Returns constructed SkRect set to integer values (0, 0, w, h). Does not validate
input; w or h may be negative.

Use to avoid a compiler warning that input may lose precision when stored.
Use SkIRect for an exact integer rectangle.

### Parameters

    w
    integer width of constructed SkRect

    h
    integer height of constructed SkRect

### Return Value

bounds (0, 0, w, h)

### Example

<fiddle-embed name="faa660ac19eaddc3f3eab57a0bddfdcb">

#### Example Output

~~~~
i_rect width: 25 f_rect width:25
i_rect width: 125000111 f_rect width:125000112
~~~~

</fiddle-embed>

### See Also

MakeXYWH MakeWH isetWH SkIRect::MakeWH

---

static constexpr SkRect MakeSize(const SkSize& size)

Returns constructed SkRect set to (0, 0, size.width(), size.height()). Does not
validate input; size.width() or size.height() may be negative.

### Parameters

    size
    SkScalar values for SkRect width and height

### Return Value

bounds (0, 0, size.width(), size.height())

### Example

<fiddle-embed name="ab2c1a55016c8de9172b77fdf69e00a2">

#### Example Output

~~~~
rect width: 25.5  height: 35.5
floor width: 25  height: 35
~~~~

</fiddle-embed>

### See Also

MakeWH MakeXYWH MakeIWH setWH SkIRect::MakeWH

---

static constexpr SkRect MakeLTRB(SkScalar l, SkScalar t, SkScalar r, SkScalar b)

Returns constructed SkRect set to (l, t, r, b). Does not sort input; SkRect may
result in fLeft greater than fRight, or fTop greater than fBottom.

### Parameters

    l
    SkScalar stored in fLeft

    t
    SkScalar stored in fTop

    r
    SkScalar stored in fRight

    b
    SkScalar stored in fBottom

### Return Value

bounds (l, t, r, b)

### Example

<fiddle-embed name="158b8dd9d02d65a5ae5ab7d1595a5b4c">

#### Example Output

~~~~
rect: 5, 35, 15, 25  isEmpty: true
rect: 5, 25, 15, 35  isEmpty: false
~~~~

</fiddle-embed>

### See Also

MakeXYWH SkIRect::MakeLTRB

---

static constexpr SkRect MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h)

Returns constructed Rect set to (x, y, x + w, y + h).
Does not validate input; w or h may be negative.

### Parameters

    x
    stored in fLeft

    y
    stored in fTop

    w
    added to x and stored in fRight

    h
    added to y and stored in fBottom

### Return Value

bounds at (x, y) with width w and height h

### Example

<fiddle-embed name="38e464dba13be11ac21e210fbf3b5afc">

#### Example Output

~~~~
rect: 5, 35, -10, 60  isEmpty: true
rect: -10, 35, 5, 60  isEmpty: false
~~~~

</fiddle-embed>

### See Also

MakeLTRB SkIRect::MakeXYWH

---

static SkRect Make(const SkISize& size)

Returns constructed SkIRect set to (0, 0, size.width(), size.height()).
Does not validate input; size.width() or size.height() may be negative.

### Parameters

    size
    integer values for SkRect width and height

### Return Value

bounds (0, 0, size.width(), size.height())

### Example

<fiddle-embed name="e866f5e4f6ac52e89acadf48e54ac8e0">

#### Example Output

~~~~
rect1 == rect2
~~~~

</fiddle-embed>

### See Also

MakeWH MakeXYWH SkRect::MakeIWH SkIRect::MakeSize

---

static SkRect Make(const SkIRect& irect)

Returns constructed SkIRect set to irect, promoting integers to scalar.
Does not validate input; fLeft may be greater than fRight, fTop may be greater
than fBottom.

### Parameters

    irect
    integer unsorted bounds

### Return Value

irect members converted to SkScalar

### Example

<fiddle-embed name="dd801faa1e60a0fe9e0657674461e063"></fiddle-embed>

### See Also

MakeLTRB

---

bool isEmpty()const

Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
to or greater than fBottom. Call sort() to reverse rectangles with negative
width() or height().

### Return Value

true if width() or height() are zero or negative

### Example

<fiddle-embed name="1d7b924d6ca2a6aef09684a8a632439c">

#### Example Output

~~~~
rect: {20, 40, 10, 50} is empty
sorted: {10, 40, 20, 50} is not empty
rect: {20, 40, 20, 50} is empty
sorted: {20, 40, 20, 50} is empty
~~~~

</fiddle-embed>

### See Also

MakeEmpty sort SkIRect::isEmpty

---

bool isSorted()const

Returns true if fLeft is equal to or less than fRight, or if fTop is equal
to or less than fBottom. Call sort() to reverse rectangles with negative
width() or height().

### Return Value

true if width() or height() are zero or positive

### Example

<fiddle-embed name="c7065a83b220a96f903dbbb65906fe7b">

#### Example Output

~~~~
rect: {20, 40, 10, 50} is not sorted
sorted: {10, 40, 20, 50} is sorted
rect: {20, 40, 20, 50} is sorted
sorted: {20, 40, 20, 50} is sorted
~~~~

</fiddle-embed>

### See Also

sort makeSorted isEmpty

---

bool isFinite()const

Returns true if all values in the rectangle are finite: SK_ScalarMin or larger,
and SK_ScalarMax or smaller.

### Return Value

true if no member is infinite or NaN

### Example

<fiddle-embed name="443fe5f8296d4cdb19cc9862a9cf77a4">

#### Example Output

~~~~
largest is finite: true
large width inf
widest is finite: false
~~~~

</fiddle-embed>

### See Also

SkScalarIsFinite SkScalarIsNaN

---

SkScalar    x()const

Returns left edge of SkRect, if sorted. Call isSorted() to see if SkRect is valid.
Call sort() to reverse fLeft and fRight if needed.

### Return Value

fLeft

### Example

<fiddle-embed name="23c77a35ac54a439a2989f840aa5cb99">

#### Example Output

~~~~
unsorted.fLeft: 15 unsorted.x(): 15
sorted.fLeft: 10 sorted.x(): 10
~~~~

</fiddle-embed>

### See Also

fLeft left() y() SkIRect::x()

---

SkScalar    y()const

Returns top edge of SkRect, if sorted. Call isEmpty() to see if SkRect may be invalid,
and sort() to reverse fTop and fBottom if needed.

### Return Value

fTop

### Example

<fiddle-embed name="c653d9017983d2a047b1fee6a481d82b">

#### Example Output

~~~~
unsorted.fTop: 25 unsorted.y(): 25
sorted.fTop: 5 sorted.y(): 5
~~~~

</fiddle-embed>

### See Also

fTop top() x() SkIRect::y()

---

SkScalar    left()const

Returns left edge of SkRect, if sorted. Call isSorted() to see if SkRect is valid.
Call sort() to reverse fLeft and fRight if needed.

### Return Value

fLeft

### Example

<fiddle-embed name="900dc96c3549795a87036d6458c4fde6">

#### Example Output

~~~~
unsorted.fLeft: 15 unsorted.left(): 15
sorted.fLeft: 10 sorted.left(): 10
~~~~

</fiddle-embed>

### See Also

fLeft x() SkIRect::left()

---

SkScalar    top()const

Returns top edge of SkRect, if sorted. Call isEmpty() to see if SkRect may be invalid,
and sort() to reverse fTop and fBottom if needed.

### Return Value

fTop

### Example

<fiddle-embed name="3cfc24b011aef1ca8ccb57c05711620c">

#### Example Output

~~~~
unsorted.fTop: 25 unsorted.top(): 25
sorted.fTop: 5 sorted.top(): 5
~~~~

</fiddle-embed>

### See Also

fTop y() SkIRect::top()

---

SkScalar    right()const

Returns right edge of SkRect, if sorted. Call isSorted() to see if SkRect is valid.
Call sort() to reverse fLeft and fRight if needed.

### Return Value

fRight

### Example

<fiddle-embed name="ca3de7e5e292b3ad3633b1c39a31d3ab">

#### Example Output

~~~~
unsorted.fRight: 10 unsorted.right(): 10
sorted.fRight: 15 sorted.right(): 15
~~~~

</fiddle-embed>

### See Also

fRight SkIRect::right()

---

SkScalar    bottom()const

Returns bottom edge of SkRect, if sorted. Call isEmpty() to see if SkRect may be invalid,
and sort() to reverse fTop and fBottom if needed.

### Return Value

fBottom

### Example

<fiddle-embed name="a98993a66616ae406d8bdc54adfb1411">

#### Example Output

~~~~
unsorted.fBottom: 5 unsorted.bottom(): 5
sorted.fBottom: 25 sorted.bottom(): 25
~~~~

</fiddle-embed>

### See Also

fBottom SkIRect::bottom()

---

SkScalar    width()const

Returns span on the x-axis. This does not check if SkRect is sorted, or if
result fits in 32-bit float; result may be negative or infinity.

### Return Value

fRight minus fLeft

### Example

<fiddle-embed name="11f8f0efe6291019fee0ac17844f6c1a">
Compare with SkIRect::width() example.

#### Example Output

~~~~
unsorted width: -5
large width: 4294967296
~~~~

</fiddle-embed>

### See Also

height() SkIRect::width()

---

SkScalar    height()const

Returns span on the y-axis. This does not check if SkRect is sorted, or if
result fits in 32-bit float; result may be negative or infinity.

### Return Value

fBottom minus fTop

### Example

<fiddle-embed name="39429e45f05240218ecd511443ab3e44">
Compare with SkIRect::height() example.

#### Example Output

~~~~
unsorted height: -5
large height: 4294967296
~~~~

</fiddle-embed>

### See Also

width() SkIRect::height()

---

SkScalar    centerX()const

Returns average of left edge and right edge. Result does not change if SkRect
is sorted. Result may overflow to infinity if SkRect is far from the origin.

### Return Value

midpoint on x-axis

### Example

<fiddle-embed name="d8439ba8d23a424fa032fb97147fd2d2">

#### Example Output

~~~~
left:  20 right:  41 centerX: 30.5
left:  20 right:  41 centerX: 30.5
left: -20 right: -41 centerX: -30.5
left: -41 right: -20 centerX: -30.5
~~~~

</fiddle-embed>

### See Also

centerY

---

SkScalar    centerY()const

Returns average of top edge and bottom edge. Result does not change if SkRect
is sorted.

### Return Value

midpoint on y-axis

### Example

<fiddle-embed name="ebeeafafeb8fe39d5ffc9115b02c2340">

#### Example Output

~~~~
left: 2e+38 right: 3e+38 centerX: 2.5e+38 safe mid x: 2.5e+38
~~~~

</fiddle-embed>

### See Also

centerX

---

bool operator==(const SkRect& a, const SkRect& b)

Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
equal to the corresponding members in b.

a and b are not equal if either contain NaN. a and b are equal if members
contain zeroes with different signs.

### Parameters

    a
    SkRect to compare

    b
    SkRect to compare

### Return Value

true if members are equal

### Example

<fiddle-embed name="c6c5b40cad7c3a839fdf576b380391a6">

#### Example Output

~~~~
tests are equal
{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
~~~~

</fiddle-embed>

### See Also

operator!=(const SkRect& a, const SkRect& b)

---

bool operator!=(const SkRect& a, const SkRect& b)

Returns true if any in a: fLeft, fTop, fRight, and fBottom; does not
equal the corresponding members in b.

a and b are not equal if either contain NaN. a and b are equal if members
contain zeroes with different signs.

### Parameters

    a
    SkRect to compare

    b
    SkRect to compare

### Return Value

true if members are not equal

### Example

<fiddle-embed name="286072f8c27ff15be9eb945fa38dc9f7">

#### Example Output

~~~~
test with NaN is not equal to itself
~~~~

</fiddle-embed>

### See Also

operator==(const SkRect& a, const SkRect& b)

---

void toQuad(SkPoint quad[4])const

Returns four points in quad that enclose SkRect ordered as: top-left, top-right,
bottom-right, bottom-left.

### Parameters

    quad
    storage for corners of SkRect

### Example

<fiddle-embed name="59a6e7d202ac17ab80ec21b233e51f59">

#### Example Output

~~~~
rect: {1, 2, 3, 4}
corners: {1, 2} {3, 2} {3, 4} {1, 4}
~~~~

</fiddle-embed>

### See Also

SkPath::addRect

---

void setBounds(const SkPoint pts[], int count)

Sets to bounds of  SkPoint array with count entries. If count is zero or smaller,
or if  SkPoint array contains an infinity or NaN, sets to (0, 0, 0, 0).

Result is either empty or sorted: fLeft is less than or equal to fRight, and
fTop is less than or equal to fBottom.

### Parameters

    pts
    SkPoint array

    count
    entries in array

### Example

<fiddle-embed name="cf0da15f48aa54fd1889e7f913601710">

#### Example Output

~~~~
count: 0 rect: 0, 0, 0, 0
added:   3, 4 count: 1 rect: 3, 4, 3, 4
added:   1, 2 count: 2 rect: 1, 2, 3, 4
added:   5, 6 count: 3 rect: 1, 2, 5, 6
added: nan, 8 count: 4 rect: 0, 0, 0, 0
~~~~

</fiddle-embed>

### See Also

set setBoundsCheck SkPath::addPoly

---

bool setBoundsCheck(const SkPoint pts[], int count)

Sets to bounds of  SkPoint array with count entries. Returns false if count is
zero or smaller, or if  SkPoint array contains an infinity or NaN; in these cases
sets SkRect to (0, 0, 0, 0).

Result is either empty or sorted: fLeft is less than or equal to fRight, and
fTop is less than or equal to fBottom.

### Parameters

    pts
    SkPoint array

    count
    entries in array

### Return Value

true if all SkPoint values are finite

### Example

<fiddle-embed name="83d879b92683b15f9daaf0c9e71c5b35">

#### Example Output

~~~~
count: 0 rect: 0, 0, 0, 0 success: true
added:   3, 4 count: 1 rect: 3, 4, 3, 4 success: true
added:   1, 2 count: 2 rect: 1, 2, 3, 4 success: true
added:   5, 6 count: 3 rect: 1, 2, 5, 6 success: true
added: nan, 8 count: 4 rect: 0, 0, 0, 0 success: false
~~~~

</fiddle-embed>

### See Also

set setBounds SkPath::addPoly

---

void setBoundsNoCheck(const SkPoint pts[], int count)

Sets to bounds of SkPoint pts array with count entries. If any SkPoint in pts
contains infinity or NaN, all SkRect dimensions are set to NaN.

### Parameters

    pts
    SkPoint array

    count
    entries in array

### Example

<fiddle-embed name="be10cb1411dbcf7e38e0198e8a9b8b0e"></fiddle-embed>

### See Also

setBoundsCheck

---

void setEmpty()

Sets SkRect to (0, 0, 0, 0).

Many other rectangles are empty; if left is equal to or greater than right,
or if top is equal to or greater than bottom. Setting all members to zero
is a convenience, but does not designate a special empty rectangle.

### Example

<fiddle-embed name="2cf67542d45ef5d7a7efb673b651ff54">

#### Example Output

~~~~
rect: {3, 4, 1, 2} is empty
rect: {0, 0, 0, 0} is empty
~~~~

</fiddle-embed>

### See Also

MakeEmpty SkIRect::setEmpty

---

void set(const SkIRect& src)

Sets SkRect to src, promoting src members from integer to scalar.
Very large values in src may lose precision.

### Parameters

    src
    integer SkRect

### Example

<fiddle-embed name="a10ad8d97062bc3f40942f47e5108917">

#### Example Output

~~~~
i_rect: {3, 4, 1, 2}
f_rect: {3, 4, 1, 2}
~~~~

</fiddle-embed>

### See Also

setLTRB SkIntToScalar

---

void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)

Sets SkRect to (left, top, right, bottom).
left and right are not sorted; left is not necessarily less than right.
top and bottom are not sorted; top is not necessarily less than bottom.

### Parameters

    left
    stored in fLeft

    top
    stored in fTop

    right
    stored in fRight

    bottom
    stored in fBottom

### Example

<fiddle-embed name="9b29ea460d69b4d47323fd9e3e17721e">

#### Example Output

~~~~
rect1: {3, 4, 1, 2}
rect2: {3, 4, 1, 2}
~~~~

</fiddle-embed>

### See Also

setLTRB setXYWH SkIRect::set

---

void setLTRB(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)

Sets SkRect to (left, top, right, bottom).
left and right are not sorted; left is not necessarily less than right.
top and bottom are not sorted; top is not necessarily less than bottom.

### Parameters

    left
    stored in fLeft

    top
    stored in fTop

    right
    stored in fRight

    bottom
    stored in fBottom

### Example

<fiddle-embed name="70692838793454c8e045d6eaf7edcbff">

#### Example Output

~~~~
rect1: {3, 4, 1, 2}
rect2: {3, 4, 1, 2}
~~~~

</fiddle-embed>

### See Also

set setXYWH SkIRect::set

---

void set(const SkPoint pts[], int count)

Sets to bounds of  SkPoint array with count entries. If count is zero or smaller,
or if  SkPoint array contains an infinity or NaN, sets SkRect to (0, 0, 0, 0).

Result is either empty or sorted: fLeft is less than or equal to fRight, and
fTop is less than or equal to fBottom.

### Parameters

    pts
    SkPoint array

    count
    entries in array

### Example

<fiddle-embed name="94295fa5197e21256171b99b4023dd48">

#### Example Output

~~~~
count: 0 rect: 0, 0, 0, 0
added:   3, 4 count: 1 rect: 3, 4, 3, 4
added:   1, 2 count: 2 rect: 1, 2, 3, 4
added:   5, 6 count: 3 rect: 1, 2, 5, 6
added: nan, 8 count: 4 rect: 0, 0, 0, 0
~~~~

</fiddle-embed>

### See Also

setBounds setBoundsCheck SkPath::addPoly

---

void set(const SkPoint& p0, const SkPoint& p1)

Sets bounds to the smallest SkRect enclosing SkPoint p0 and p1. The result is
sorted and may be empty. Does not check to see if values are finite.

### Parameters

    p0
    corner to include

    p1
    corner to include

### Example

<fiddle-embed name="ee72450381f768f3869153cdbeccdc3e">
p0 and p1 may be swapped and have the same effect unless one contains NaN.

</fiddle-embed>

### See Also

setBounds setBoundsCheck

---

void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height)

Sets Rect to (x, y, x + width, y + height).
Does not validate input; width or height may be negative.

### Parameters

    x
    stored in fLeft

    y
    stored in fTop

    width
    added to x and stored in fRight

    height
    added to y and stored in fBottom

### Example

<fiddle-embed name="373cce4c61b9da0384b735b838765163">

#### Example Output

~~~~
rect: 5, 35, -10, 60  isEmpty: true
rect: -10, 35, 5, 60  isEmpty: false
~~~~

</fiddle-embed>

### See Also

MakeXYWH setLTRB set SkIRect::setXYWH

---

void setWH(SkScalar width, SkScalar height)

Sets SkRect to (0, 0, width, height). Does not validate input;
width or height may be negative.

### Parameters

    width
    stored in fRight

    height
    stored in fBottom

### Example

<fiddle-embed name="9cb5fee17802fa49341f3707bdf5d235">

#### Example Output

~~~~
rect: 0, 0, -15, 25  isEmpty: true
rect: -15, 0, 0, 25  isEmpty: false
~~~~

</fiddle-embed>

### See Also

MakeWH setXYWH isetWH

---

void iset(int left, int top, int right, int bottom)

Sets SkRect to (left, top, right, bottom).
All parameters are promoted from integer to scalar.
left and right are not sorted; left is not necessarily less than right.
top and bottom are not sorted; top is not necessarily less than bottom.

### Parameters

    left
    promoted to SkScalar and stored in fLeft

    top
    promoted to SkScalar and stored in fTop

    right
    promoted to SkScalar and stored in fRight

    bottom
    promoted to SkScalar and stored in fBottom

### Example

<fiddle-embed name="18532f1aa90b76364fb8d7ea072f1892">

#### Example Output

~~~~
rect1: {3, 4, 1, 2}
rect2: {3, 4, 1, 2}
~~~~

</fiddle-embed>

### See Also

set setLTRB SkIRect::set SkIntToScalar

---

void isetWH(int width, int height)

Sets SkRect to (0, 0, width, height).
width and height may be zero or negative. width and height are promoted from
integer to SkScalar, large values may lose precision.

### Parameters

    width
    promoted to SkScalar and stored in fRight

    height
    promoted to SkScalar and stored in fBottom

### Example

<fiddle-embed name="ee6000080fc7123214ea404018cf9176">

#### Example Output

~~~~
rect1: {0, 0, 1, 2}
rect2: {0, 0, 1, 2}
~~~~

</fiddle-embed>

### See Also

MakeWH MakeXYWH iset() SkIRect:MakeWH

---

SkRect makeOffset(SkScalar dx, SkScalar dy)const

Returns SkRect offset by (dx, dy).

If dx is negative, SkRect returned is moved to the left.
If dx is positive, SkRect returned is moved to the right.
If dy is negative, SkRect returned is moved upward.
If dy is positive, SkRect returned is moved downward.

### Parameters

    dx
    added to fLeft and fRight

    dy
    added to fTop and fBottom

### Return Value

SkRect offset on axes, with original width and height

### Example

<fiddle-embed name="98841ab0a932f99cccd8e6a34d94ba05">

#### Example Output

~~~~
rect: 10, 50, 20, 60  isEmpty: false
rect: 25, 82, 35, 92  isEmpty: false
~~~~

</fiddle-embed>

### See Also

offset() makeInset makeOutset SkIRect::makeOffset

---

SkRect makeInset(SkScalar dx, SkScalar dy)const

Returns SkRect, inset by (dx, dy).

If dx is negative, SkRect returned is wider.
If dx is positive, SkRect returned is narrower.
If dy is negative, SkRect returned is taller.
If dy is positive, SkRect returned is shorter.

### Parameters

    dx
    added to fLeft and subtracted from fRight

    dy
    added to fTop and subtracted from fBottom

### Return Value

SkRect inset symmetrically left and right, top and bottom

### Example

<fiddle-embed name="b8d32ab2f7ea3d4d5fb5a4ea2156f1c5">

#### Example Output

~~~~
rect: 10, 50, 20, 60  isEmpty: false
rect: 25, 82, 5, 28  isEmpty: true
~~~~

</fiddle-embed>

### See Also

inset() makeOffset makeOutset SkIRect::makeInset

---

SkRect makeOutset(SkScalar dx, SkScalar dy)const

Returns SkRect, outset by (dx, dy).

If dx is negative, SkRect returned is narrower.
If dx is positive, SkRect returned is wider.
If dy is negative, SkRect returned is shorter.
If dy is positive, SkRect returned is taller.

### Parameters

    dx
    subtracted to fLeft and added from fRight

    dy
    subtracted to fTop and added from fBottom

### Return Value

SkRect outset symmetrically left and right, top and bottom

### Example

<fiddle-embed name="87176fc60914cbca9c6a20998a033c24">

#### Example Output

~~~~
rect: 10, 50, 20, 60  isEmpty: false
rect: -5, 18, 35, 92  isEmpty: false
~~~~

</fiddle-embed>

### See Also

outset() makeOffset makeInset SkIRect::makeOutset

---

void offset(SkScalar dx, SkScalar dy)

Offsets SkRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.

If dx is negative, moves SkRect to the left.
If dx is positive, moves SkRect to the right.
If dy is negative, moves SkRect upward.
If dy is positive, moves SkRect downward.

### Parameters

    dx
    offset added to fLeft and fRight

    dy
    offset added to fTop and fBottom

### Example

<fiddle-embed name="04eb33f0fd376f2942ca5f1c7f6cbcfc">

#### Example Output

~~~~
rect: 15, 27, 55, 86
~~~~

</fiddle-embed>

### See Also

offsetTo makeOffset SkIRect::offset

---

void offset(const SkPoint& delta)

Offsets SkRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to
fTop, fBottom.

If delta.fX is negative, moves SkRect to the left.
If delta.fX is positive, moves SkRect to the right.
If delta.fY is negative, moves SkRect upward.
If delta.fY is positive, moves SkRect downward.

### Parameters

    delta
    added to SkRect

### Example

<fiddle-embed name="b24cf65561c98c1858a06c39f10fb797">

#### Example Output

~~~~
rect: 15, 27, 55, 86
~~~~

</fiddle-embed>

### See Also

offsetTo makeOffset SkIRect::offset

---

void offsetTo(SkScalar newX, SkScalar newY)

Offsets SkRect so that fLeft equals newX, and fTop equals newY. width and height
are unchanged.

### Parameters

    newX
    stored in fLeft, preserving width()

    newY
    stored in fTop, preserving height()

### Example

<fiddle-embed name="bedb04b7b3e1af3e8039f9cffe66989e">

#### Example Output

~~~~
rect: 15, 27, 55, 86
~~~~

</fiddle-embed>

### See Also

offset makeOffset setXYWH SkIRect::offsetTo

---

void inset(SkScalar dx, SkScalar dy)

Insets SkRect by (dx, dy).

If dx is positive, makes SkRect narrower.
If dx is negative, makes SkRect wider.
If dy is positive, makes SkRect shorter.
If dy is negative, makes SkRect taller.

### Parameters

    dx
    added to fLeft and subtracted from fRight

    dy
    added to fTop and subtracted from fBottom

### Example

<fiddle-embed name="dae21340941dc6e4d048816dfd9f204c">

#### Example Output

~~~~
rect: 15, 27, 45, 60
~~~~

</fiddle-embed>

### See Also

outset makeInset SkIRect::inset

---

void outset(SkScalar dx, SkScalar dy)

Outsets SkRect by (dx, dy).

If dx is positive, makes SkRect wider.
If dx is negative, makes SkRect narrower.
If dy is positive, makes SkRect taller.
If dy is negative, makes SkRect shorter.

### Parameters

    dx
    subtracted to fLeft and added from fRight

    dy
    subtracted to fTop and added from fBottom

### Example

<fiddle-embed name="861f873ba660af8c8bf8b0b83d829cf4">

#### Example Output

~~~~
rect: 5, 1, 55, 86
~~~~

</fiddle-embed>

### See Also

inset makeOutset SkIRect::outset

Rects intersect when they enclose a common area. To intersect, each of the pair
must describe area; fLeft is less than fRight, and fTop is less than fBottom;
isEmpty() returns false. The intersection of Rect pair can be described by:
(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)).

The intersection is only meaningful if the resulting Rect is not empty and
describes an area: fLeft is less than fRight, and fTop is less than fBottom.

---

bool contains(SkScalar x, SkScalar y)const

Returns true if: fLeft <= x < fRight && fTop <= y < fBottom.
Returns false if SkRect is empty.

### Parameters

    x
    test SkPoint x-coordinate

    y
    test SkPoint y-coordinate

### Return Value

true if (x, y) is inside SkRect

### Example

<fiddle-embed name="85be528a78945a6dc4f7dccb80a80746">

#### Example Output

~~~~
rect: (30, 50, 40, 60) contains (30, 50)
rect: (30, 50, 40, 60) does not contain (39, 49)
rect: (30, 50, 40, 60) does not contain (29, 59)
~~~~

</fiddle-embed>

### See Also

SkIRect::contains SkRRect::contains

---

bool contains(const SkRect& r)const

Returns true if SkRect contains r.
Returns false if SkRect is empty or r is empty.

SkRect contains r when SkRect area completely includes r area.

### Parameters

    r
    SkRect contained

### Return Value

true if all sides of SkRect are outside r

### Example

<fiddle-embed name="92f9e6aa5bb76791139a24cf7d8df99e">

#### Example Output

~~~~
rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
~~~~

</fiddle-embed>

### See Also

SkIRect::contains

---

bool contains(const SkIRect& r)const

Returns true if SkRect contains r.
Returns false if SkRect is empty or r is empty.

SkRect contains r when SkRect area completely includes r area.

### Parameters

    r
    SkIRect contained

### Return Value

true if all sides of SkRect are outside r

### Example

<fiddle-embed name="dd58b699551dd44026a2c6386be27d88">

#### Example Output

~~~~
rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
~~~~

</fiddle-embed>

### See Also

SkIRect::contains

---

bool intersect(const SkRect& r)

Returns true if SkRect intersects r, and sets SkRect to intersection.
Returns false if SkRect does not intersect r, and leaves SkRect unchanged.

Returns false if either r or SkRect is empty, leaving SkRect unchanged.

### Parameters

    r
    limit of result

### Return Value

true if r and SkRect have area in common

### Example

<fiddle-embed name="5d0b12e0ef6f1c181dddded4274230ca">
Two SkDebugf calls are required. If the calls are combined, their arguments
may not be evaluated in left to right order: the printed intersection may
be before or after the call to intersect.

#### Example Output

~~~~
intersection: 30, 60, 50, 80
~~~~

</fiddle-embed>

### See Also

intersects Intersects join SkIRect::intersect

---

bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)

Constructs SkRect to intersect from (left, top, right, bottom). Does not sort
construction.

Returns true if SkRect intersects construction, and sets SkRect to intersection.
Returns false if SkRect does not intersect construction, and leaves SkRect unchanged.

Returns false if either construction or SkRect is empty, leaving SkRect unchanged.

### Parameters

    left
    x-axis minimum of constructed SkRect

    top
    y-axis minimum of constructed SkRect

    right
    x-axis maximum of constructed SkRect

    bottom
    y-axis maximum of constructed SkRect

### Return Value

true if construction and SkRect have area in common

### Example

<fiddle-embed name="5002f65a72def2787086a33131933e70">
Two SkDebugf calls are required. If the calls are combined, their arguments
may not be evaluated in left to right order: the printed intersection may
be before or after the call to intersect.

#### Example Output

~~~~
intersection: 30, 60, 50, 80
~~~~

</fiddle-embed>

### See Also

intersects Intersects join SkIRect::intersect

---

bool intersect(const SkRect& a, const SkRect& b)

Returns true if a intersects b, and sets SkRect to intersection.
Returns false if a does not intersect b, and leaves SkRect unchanged.

Returns false if either a or b is empty, leaving SkRect unchanged.

### Parameters

    a
    SkRect to intersect

    b
    SkRect to intersect

### Return Value

true if a and b have area in common

### Example

<fiddle-embed name="d610437a65dd3e952719efe605cbd0c7">

#### Example Output

~~~~
intersection: 30, 60, 50, 80
~~~~

</fiddle-embed>

### See Also

intersects Intersects join SkIRect::intersect

---

bool intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)const

Constructs SkRect to intersect from (left, top, right, bottom). Does not sort
construction.

Returns true if SkRect intersects construction.
Returns false if either construction or SkRect is empty, or do not intersect.

### Parameters

    left
    x-axis minimum of constructed SkRect

    top
    y-axis minimum of constructed SkRect

    right
    x-axis maximum of constructed SkRect

    bottom
    y-axis maximum of constructed SkRect

### Return Value

true if construction and SkRect have area in common

### Example

<fiddle-embed name="7145dc17ebce4f54e892102f6c98e811">

#### Example Output

~~~~
intersection
~~~~

</fiddle-embed>

### See Also

intersect Intersects SkIRect::Intersects

---

bool intersects(const SkRect& r)const

Returns true if SkRect intersects r.
Returns false if either r or SkRect is empty, or do not intersect.

### Parameters

    r
    SkRect to intersect

### Return Value

true if r and SkRect have area in common

### Example

<fiddle-embed name="ca37b4231b21eb8296cb19ba9e0c781b">

#### Example Output

~~~~
intersection
~~~~

</fiddle-embed>

### See Also

intersect Intersects SkIRect::Intersects

---

static bool Intersects(const SkRect& a, const SkRect& b)

Returns true if a intersects b.
Returns false if either a or b is empty, or do not intersect.

### Parameters

    a
    SkRect to intersect

    b
    SkRect to intersect

### Return Value

true if a and b have area in common

### Example

<fiddle-embed name="795061764b10c9e05efb466c9cb60644">

#### Example Output

~~~~
intersection
~~~~

</fiddle-embed>

### See Also

intersect intersects SkIRect::Intersects

---

void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)

Constructs SkRect to intersect from (left, top, right, bottom). Does not sort
construction.

Sets SkRect to the union of itself and the construction.

Has no effect if construction is empty. Otherwise, if SkRect is empty, sets
SkRect to construction.

### Parameters

    left
    x-axis minimum of constructed SkRect

    top
    y-axis minimum of constructed SkRect

    right
    x-axis maximum of constructed SkRect

    bottom
    y-axis maximum of constructed SkRect

### Example

<fiddle-embed name="afa9c6b4d05bb669db07fe0b7b97e6aa">

#### Example Output

~~~~
join: 10, 20, 55, 65
~~~~

</fiddle-embed>

### See Also

joinNonEmptyArg joinPossiblyEmptyRect SkIRect::join

---

void join(const SkRect& r)

Sets SkRect to the union of itself and r.

Has no effect if r is empty. Otherwise, if SkRect is empty, sets
SkRect to r.

### Parameters

    r
    expansion SkRect

### Example

<fiddle-embed name="26500032494cf93c5fa3423110fe82af">

#### Example Output

~~~~
join: 10, 20, 55, 65
~~~~

</fiddle-embed>

### See Also

joinNonEmptyArg joinPossiblyEmptyRect SkIRect::join

---

void joinNonEmptyArg(const SkRect& r)

Sets SkRect to the union of itself and r.

Asserts if r is empty and SK_DEBUG is defined.
If SkRect is empty, sets SkRect to r.

May produce incorrect results if r is empty.

### Parameters

    r
    expansion SkRect

### Example

<fiddle-embed name="88439de2aa0911262c60c0eb506396cb">
Since Rect is not sorted, first result is copy of toJoin.

#### Example Output

~~~~
rect: 50, 60, 55, 65
sorted: 10, 0, 55, 100
~~~~

</fiddle-embed>

### See Also

join joinPossiblyEmptyRect SkIRect::join

---

void joinPossiblyEmptyRect(const SkRect& r)

Sets SkRect to the union of itself and the construction.

May produce incorrect results if SkRect or r is empty.

### Parameters

    r
    expansion SkRect

### Example

<fiddle-embed name="a476548d0001296afd8e58c1eba1b70b">
Since Rect is not sorted, first result is not useful.

#### Example Output

~~~~
rect: 10, 60, 55, 65
sorted: 10, 0, 55, 100
~~~~

</fiddle-embed>

### See Also

joinNonEmptyArg join SkIRect::join

---

void round(SkIRect* dst)const

Sets IRect by adding 0.5 and discarding the fractional portion of Rect
members, using (SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop),
SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom)).

### Parameters

    dst
    storage for IRect

### Example

<fiddle-embed name="8b9e5a9af0a9b878f76919534d88f41e">

#### Example Output

~~~~
round: 31, 51, 41, 61
~~~~

</fiddle-embed>

### See Also

roundIn roundOut SkScalarRoundToInt

---

void roundOut(SkIRect* dst)const

Sets IRect by discarding the fractional portion of fLeft and fTop; and rounding
up fRight and fBottom, using
(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop),
SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)).

### Parameters

    dst
    storage for IRect

### Example

<fiddle-embed name="0bd13d7e6426ae7a3befa2ab151ac5fc">

#### Example Output

~~~~
round: 30, 50, 41, 61
~~~~

</fiddle-embed>

### See Also

roundIn round SkScalarRoundToInt

---

void roundOut(SkRect* dst)const

Sets Rect by discarding the fractional portion of fLeft and fTop; and rounding
up fRight and fBottom, using
(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop),
SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)).

### Parameters

    dst
    storage for Rect

### Example

<fiddle-embed name="e09a6a12869a8ac21e9c2af98a5bb686">

#### Example Output

~~~~
round: 30, 50, 41, 61
~~~~

</fiddle-embed>

### See Also

roundIn round SkScalarRoundToInt

---

void roundIn(SkIRect* dst)const

Sets Rect by rounding up fLeft and fTop; and discarding the fractional portion
of fRight and fBottom, using
(SkScalarCeilToInt(fLeft), SkScalarCeilToInt(fTop),
SkScalarFloorToInt(fRight), SkScalarFloorToInt(fBottom)).

### Parameters

    dst
    storage for IRect

### Example

<fiddle-embed name="abb337da8fc1891f016c61258681c64c">

#### Example Output

~~~~
round: 31, 51, 40, 60
~~~~

</fiddle-embed>

### See Also

roundOut round SkScalarRoundToInt

---

SkIRect round()const

Returns IRect by adding 0.5 and discarding the fractional portion of Rect
members, using (SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop),
SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom)).

### Return Value

rounded IRect

### Example

<fiddle-embed name="ef7ae1dd522c235b0afe41b55a624f46">

#### Example Output

~~~~
round: 31, 51, 41, 61
~~~~

</fiddle-embed>

### See Also

roundOut roundIn SkScalarRoundToInt

---

SkIRect roundOut()const

Sets IRect by discarding the fractional portion of fLeft and fTop; and rounding
up fRight and fBottom, using
(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop),
SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)).

### Return Value

rounded IRect

### Example

<fiddle-embed name="05f0f65ae148f192656cd87df90f1d57">

#### Example Output

~~~~
round: 30, 50, 41, 61
~~~~

</fiddle-embed>

### See Also

round roundIn SkScalarRoundToInt

---

void sort()

Swaps fLeft and fRight if fLeft is greater than fRight; and swaps
fTop and fBottom if fTop is greater than fBottom. Result may be empty;
and width() and height() will be zero or positive.

### Example

<fiddle-embed name="e624fe398e3d770b573c09fc74c0c400">

#### Example Output

~~~~
rect: 30.5, 50.5, 20.5, 10.5
sorted: 20.5, 10.5, 30.5, 50.5
~~~~

</fiddle-embed>

### See Also

makeSorted SkIRect::sort isSorted

---

SkRect makeSorted()const

Returns SkRect with fLeft and fRight swapped if fLeft is greater than fRight; and
with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty;
and width() and height() will be zero or positive.

### Return Value

sorted SkRect

### Example

<fiddle-embed name="f59567042b87f6b26f9bfeeb04468032">

#### Example Output

~~~~
rect: 30.5, 50.5, 20.5, 10.5
sorted: 20.5, 10.5, 30.5, 50.5
~~~~

</fiddle-embed>

### See Also

sort SkIRect::makeSorted isSorted

---

const SkScalar* asScalars()const

Returns pointer to first scalar in SkRect, to treat it as an array with four
entries.

### Return Value

pointer to fLeft

### Example

<fiddle-embed name="e1ea5f949d80276f3637931eae93a07c">

#### Example Output

~~~~
rect.asScalars() == &rect.fLeft
~~~~

</fiddle-embed>

### See Also

toQuad

---

void dump(bool asHex)const

Writes text representation of SkRect to standard output. Set asHex to true to
generate exact binary representations of floating point numbers.

### Parameters

    asHex
    true if SkScalar values are written as hexadecimal

### Example

<fiddle-embed name="cea049ffff702a5923da41fe0ae0763b">

#### Example Output

~~~~
SkRect::MakeLTRB(20, 30, 40, 50);
SkRect::MakeLTRB(SkBits2Float(0x41a00000), /* 20.000000 */
SkBits2Float(0x41f00000), /* 30.000000 */
SkBits2Float(0x42200000), /* 40.000000 */
SkBits2Float(0x42480000)  /* 50.000000 */);
~~~~

</fiddle-embed>

### See Also

dumpHex

---

void dump()const

Writes text representation of SkRect to standard output. The representation may be
directly compiled as C++ code. Floating point values are written
with limited precision; it may not be possible to reconstruct original SkRect
from output.

### Example

<fiddle-embed name="9fb76971b1a104a2a59816e0392267a7">

#### Example Output

~~~~
SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7);
rect is not equal to copy
~~~~

</fiddle-embed>

### See Also

dumpHex

---

void dumpHex()const

Writes text representation of Rect to standard output. The representation may be
directly compiled as C++ code. Floating point values are written
in hexadecimal to preserve their exact bit pattern. The output reconstructs the
original Rect.

Use instead of dump() when submitting
bug reports against Skia .

### Example

<fiddle-embed name="824b5a3fcfd46a7e1c5f9e3c16e6bb39">

#### Example Output

~~~~
SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
SkBits2Float(0x3f2aaaab), /* 0.666667 */
SkBits2Float(0x40266666), /* 2.600000 */
SkBits2Float(0x40e00000)  /* 7.000000 */);
rect is equal to copy
~~~~

</fiddle-embed>

### See Also

dump


text:
package org.gluu.model;

public class LocaleSupported {

	private String locale;
	private String displayName;

	public LocaleSupported() {
	}

	public LocaleSupported(String locale, String displayName) {
		this.locale = locale;
		this.displayName = displayName;
	}

	public String getLocale() {
		return locale;
	}
	public void setLocale(String locale) {
		this.locale = locale;
	}
	public String getDisplayName() {
		return displayName;
	}
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

}

redpajama_set_name: RedPajamaGithub


text:
<?php namespace Anomaly\Streams\Platform\Addon\FieldType;

/**
 * Class FieldTypeInput
 *
 * @link   http://pyrocms.com/
 * @author PyroCMS, Inc. <support@pyrocms.com>
 * @author Ryan Thompson <ryan@pyrocms.com>
 */
class FieldTypeInput
{

    /**
     * The parent field type.
     *
     * @var FieldType
     */
    protected $fieldType;

    /**
     * Create a new FieldTypeInput instance.
     *
     * @param FieldType $fieldType
     */
    public function __construct(FieldType $fieldType)
    {
        $this->fieldType = $fieldType;
    }
}


text:
import logging
import time
import abc
from collections import Counter

from sts.replay_event import *
from sts.event_dag import EventDag
from sts.control_flow.replayer import Replayer
from sts.control_flow.base import ReplaySyncCallback
from sts.control_flow.snapshot_utils import *
from sts.replay_event import InternalEvent, NOPInput
from sts.util.rpc_forker import LocalForker
from sts.util.convenience import find
from sts.input_traces.log_parser import parse

log = logging.getLogger("peeker")

# TODO(cs): is it problematic if we stop responding to OFP_PING / LLDP during
# peek()?

# TODO(cs): peek() should be run as a subprocesses to cope with memory
# constraints, as in mcs_finder. We would need to refactor the class variables
# (convert them to RPC return values, as in client_stats_dict()) below to enable this.

class Peeker(object):
  ''' Peekers are DAG `transformers' that infer the internal events that are or
  are not going to occur for a given event subsequence. '''
  __metaclass__ = abc.ABCMeta
  # { % of inferred fingerprints that were ambiguous ->
  #   # of replays where this % occurred }
  ambiguous_counts = Counter()
  # { class of event -> # occurences of ambiguity }
  ambiguous_events = Counter()

  def __init__(self, simulation_cfg, default_wait_time_seconds=0.05,
               epsilon_time=0.05):
    self.simulation_cfg = simulation_cfg
    self.default_wait_time_seconds = default_wait_time_seconds
    self.epsilon_time = epsilon_time

  @abc.abstractmethod
  def peek(self, dag):
    '''
    Return a transformed EventDag complete with the internal events that
    are going to occur for the input sequence reflected in the given
    EventDag

    Pre: there is not a simulation (i.e. running controller) in progress
    '''
    pass

  def get_wait_time_seconds(self, first_event, second_event):
    if first_event is None or second_event is None:
      return self.default_wait_time_seconds
    else:
      return second_event.time.as_float() - first_event.time.as_float() + \
             self.epsilon_time

class SnapshotPeeker(Peeker):
  ''' O(n) peeker that takes controller snapshots at each input, peeks
  forward, then restarts the snapshot up until the next input'''
  def __init__(self, simulation_cfg, default_wait_time_seconds=0.05,
               epsilon_time=0.05, **kwargs):
    if len(simulation_cfg.controller_configs) != 1:
      raise ValueError("Only one controller supported for snapshotting")
    if simulation_cfg.controller_configs[0].sync is not None:
      raise ValueError("STSSyncProto currently incompatible with snapshotting")
    super(SnapshotPeeker, self).__init__(simulation_cfg,
                                         default_wait_time_seconds=default_wait_time_seconds,
                                         epsilon_time=epsilon_time)
    self.forker = LocalForker()
    if 'default_dp_permit' in kwargs and not kwargs['default_dp_permit']:
      raise ValueError('''Non-default DP Permit not currently supported '''
                       '''Please implement the TODO near the sleep() call '''
                       '''in play_forward()''')
    kwargs['default_dp_permit'] = True
    if 'pass_through_whitelisted_messages' not in kwargs:
      kwargs['pass_through_whitelisted_messages'] = False
    self.kwargs = kwargs
    unknown_kwargs = [ k for k in kwargs.keys() if k not in Replayer.kwargs ]
    if unknown_kwargs != []:
      raise ValueError("Unknown kwargs %s" % str(unknown_kwargs))

  def setup_simulation(self):
    # TODO(cs): currently assumes that STSSyncProto is not used alongside
    # snapshotting.
    # N.B. bootstrap() does not connect switches to controllers.
    # ConnectionToControllers is an input event, which we peek() for like
    # any other input event.
    simulation = self.simulation_cfg.bootstrap(ReplaySyncCallback(None))
    simulation.openflow_buffer.pass_through_whitelisted_packets = self.kwargs['pass_through_whitelisted_messages']
    controller = simulation.controller_manager.controllers[0]
    return (simulation, controller)

  def peek(self, dag):
    '''
    If dag.events == [], returns immediately.

    If dag.events != [], assumes that isinstance(dag.events[0], ConnectToControllers)
    '''
    if dag.input_events == []:
      return dag
    # post: len(dag.input_events) > 0

    unsupported_types = [ProcessFlowMod, DataplaneDrop]
    if find(lambda e: type(e) in unsupported_types, dag.events) is not None:
      raise ValueError('''Delayed flow_mods not yet supported. Please '''
                       '''implement the TODO near the sleep() call in play_forward()''')

    if not isinstance(dag.events[0], ConnectToControllers):
      raise ValueError("First event must be ConnectToControllers")

    simulation = None
    try:
      # Inferred events includes input events and internal events
      inferred_events = []

      (simulation, controller) = self.setup_simulation()

      # dag.input_events returns only prunable input events. We also need
      # include ConnectToControllers, which is a non-prunable input event.
      assert(dag.input_events[0] != dag.events[0])
      snapshot_inputs = [dag.events[0]] + dag.input_events

      # The input event from the previous iteration, followed by the internal
      # events that were inferred from the previous peek().
      # Since we assume that the first event is always ConnectToControllers,
      # there are never internal events (nor input events) preceding the
      # initial ConnectToControllers.
      # TODO(cs): might not want to contrain the caller's dag in this way.
      events_inferred_last_iteration = []

      for inject_input_idx in xrange(0, len(snapshot_inputs)):
        inject_input = get_inject_input(inject_input_idx, snapshot_inputs)
        following_input = get_following_input(inject_input_idx, snapshot_inputs)
        expected_internal_events = \
           get_expected_internal_events(inject_input, following_input, dag.events)

        log.debug("peek()'ing after input %d (%s)" %
                  (inject_input_idx, str(inject_input)))

        inferred_events += events_inferred_last_iteration

        # We replay events_inferred_last_iteration (internal events preceding
        # inject_input), as well as a NOPInput with the same timestamp as inject_input
        # to ensure that the timing is the same before peek()ing.
        fencepost = NOPInput(time=inject_input.time, round=inject_input.round)
        dag_interval = EventDag(events_inferred_last_iteration + [fencepost])

        if expected_internal_events == []:
          # Optimization: if no internal events occured between this input and the
          # next, no need to peek(), just bring the simulation's state forward up to
          # inject_input
          log.debug("Optimization: no expected internal events")
          Peeker.ambiguous_counts[0.0] += 1
          self.replay_interval(simulation, dag_interval, 0)
          events_inferred_last_iteration = [inject_input]
          continue

        wait_time_seconds = self.get_wait_time_seconds(inject_input, following_input)
        (found_events, snapshotter) = self.find_internal_events(simulation, controller,
                                                                dag_interval, inject_input,
                                                                wait_time_seconds)
        events_inferred_last_iteration = [inject_input]
        events_inferred_last_iteration += match_and_filter(found_events, expected_internal_events)
        snapshotter.snapshot_proceed()

      # Don't forget the final iteration's output
      inferred_events += events_inferred_last_iteration
    finally:
      if simulation is not None:
        simulation.clean_up()

    return EventDag(inferred_events)

  def replay_interval(self, simulation, dag_interval, initial_wait_seconds):
    assert(dag_interval.events != [])
    # TODO(cs): set EventScheduler's epsilon_seconds parameter?
    replayer = Replayer(self.simulation_cfg, dag_interval,
                        initial_wait=initial_wait_seconds,
                        **self.kwargs)
    replayer.simulation = simulation
    if 'pass_through_sends' in self.kwargs and self.kwargs['pass_through_sends']:
      replayer.set_pass_through_sends(simulation)
    replayer.run_simulation_forward()

  def find_internal_events(self, simulation, controller, dag_interval,
                           inject_input, wait_time_seconds):
    initial_wait_seconds = (inject_input.time.as_float() -
                            dag_interval.events[-1].time.as_float())
    self.replay_interval(simulation, dag_interval, initial_wait_seconds)
    # Now peek() for internal events following inject_input
    return self.snapshot_and_play_forward(simulation, controller,
                                          inject_input, wait_time_seconds)

  def snapshot_and_play_forward(self, simulation, controller, inject_input, wait_time_seconds):
    snapshotter = Snapshotter(simulation, controller)
    snapshotter.snapshot_controller()

    # Here we also fork() ourselves (the network simulator), since we need
    # switches to respond to messages, and potentially change their state in
    # order to properly peek().
    # TODO(cs): I believe that to be technically correct we need to use Chandy-Lamport
    # here, since STS + POX = a distributed system.
    def play_forward_and_marshal():
      # Can't marshal the simulation object, so use this method as a closure
      # instead.
      # N.B. depends on LocalForker() -- cannot be used with RemoteForker().
      # TODO(cs): even though DataplaneDrops are technically InputEvents, they
      # may time out, and we might do well to try to infer this somehow.
      found_events = play_forward(simulation, inject_input, wait_time_seconds)
      # TODO(cs): DataplaneDrops are a special case of an InputEvent that may
      # time out. We should check whether the input for this peek() was a
      # DataplaneDrop, and return whether it timed out.
      return [ e.to_json() for e in found_events ]

    self.forker.register_task("snapshot_fork_task", play_forward_and_marshal)
    # N.B. play_forward cleans up the simulation, including snaphotted controller
    unmarshalled_found_events = self.forker.fork("snapshot_fork_task")
    found_events = parse(unmarshalled_found_events)

    # Finally, bring the controller back to the state it was at just after
    # injecting inject_input
    # N.B. this must be invoked in the parent process (not a forker.fork()ed
    # child), since it mutates class variables in Controller.
    return (found_events, snapshotter)

class PrefixPeeker(Peeker):
  ''' O(n^2) peeker that replays each prefix of the subseqeuence from the beginning. '''
  def __init__(self, simulation_cfg, default_wait_time_seconds=0.05,
               epsilon_time=0.05):
    super(PrefixPeeker, self).__init__(simulation_cfg,
                                       default_wait_time_seconds=default_wait_time_seconds,
                                       epsilon_time=epsilon_time)
    try:
      import pytrie
    except ImportError:
      raise RuntimeError("Need to install pytrie: `sudo pip install pytrie`")
    # The prefix trie stores lists of input events as keys,
    # and lists of both input and internal events as values
    # Note that we pass the trie around between DAG views
    self._prefix_trie = pytrie.Trie()

  def peek(self, dag):
    ''' Infer which internal events are/aren't going to occur (for the entire
    sequence of input events in dag)'''
    # TODO(cs): optimization: write the prefix trie to a file, in case we want to run
    # FindMCS again?
    if len(dag.input_events) == 0:
      # Postcondition: input_events[-1] is not None
      #                and self._events_list[-1] is not None
      return dag

    # dag.input_events returns only prunable input events. We also need
    # include ConnectToControllers, which is a non-prunable input event.
    if not isinstance(dag.events[0], ConnectToControllers):
      raise ValueError("First event must be ConnectToControllers")
    assert(dag.input_events[0] != dag.events[0])
    input_events = [dag.events[0]] + dag.input_events

    # Initilize current_input_prefix to the longest_match prefix we've
    # inferred previously (or [] if this is an entirely new prefix)
    current_input_prefix = list(self._prefix_trie\
                                .longest_prefix(input_events, default=[]))
    log.debug("Current input prefix: %s" % str(current_input_prefix))

    # The value is both internal events and input events (values of the trie)
    # leading up, but not including the next input following the tail of the
    # prefix.
    # Note that we assume that there are no internal events before the first
    # input event (i.e. we assume quiescence)
    inferred_events = list(self._prefix_trie\
                           .longest_prefix_value(input_events, default=[]))
    log.debug("Current inferred_events: %s" % str(inferred_events))
    inject_input_idx = len(current_input_prefix)

    # While we still have inputs to inject
    while inject_input_idx < len(input_events):
      # The input we're about to inject
      inject_input = input_events[inject_input_idx]
      following_input = get_following_input(inject_input_idx, dag.input_events)

      # The input following the one we're going to inject
      log.debug("peek()'ing after input %d" % (inject_input_idx))

      expected_internal_events = \
        get_expected_internal_events(inject_input, following_input, dag.events)

      # Optimization: if no internal events occured between this input and the
      # next, no need to peek()
      if expected_internal_events == []:
        log.debug("Optimization: no expected internal events")
        newly_inferred_events = []
        Peeker.ambiguous_counts[0.0] += 1
      else:
        wait_time_seconds = self.get_wait_time_seconds(inject_input, following_input)
        # We inject a NOPInput with the same timestamp as inject_input
        # to ensure that the timing is the same before peek()ing, then replay
        # inject_input in play_forward()
        fencepost = NOPInput(time=inject_input.time, round=inject_input.round)
        replay_dag = EventDag(inferred_events + [ fencepost ])
        found_events = self.find_internal_events(replay_dag, inject_input, wait_time_seconds)
        newly_inferred_events = match_and_filter(found_events, expected_internal_events)

      (current_input_prefix,
       inferred_events) = self._update_trie(current_input_prefix, inject_input,
                                            inferred_events, newly_inferred_events)
      inject_input_idx += 1

    return EventDag(inferred_events)

  def find_internal_events(self, replay_dag, inject_input, wait_time_seconds):
    ''' Replay the replay_dag, then wait for wait_time_seconds and collect internal
        events that occur. Return the list of internal events. '''
    replayer = Replayer(self.simulation_cfg, replay_dag)
    log.debug("Replaying prefix")
    simulation = replayer.simulate()
    newly_inferred_events = play_forward(simulation, inject_input, wait_time_seconds)
    return newly_inferred_events

  def _update_trie(self, current_input_prefix, inject_input, inferred_events,
                   newly_inferred_events):
    ''' Update the trie for this prefix '''
    current_input_prefix = list(current_input_prefix)
    current_input_prefix.append(inject_input)
    # Make sure to prepend the input we just injected
    inferred_events = list(inferred_events)
    inferred_events.append(inject_input)
    inferred_events += newly_inferred_events
    self._prefix_trie[current_input_prefix] = inferred_events
    return (current_input_prefix, inferred_events)

def get_inject_input(inject_input_idx, input_events):
  ''' Return the input at inject_input_index, or None if
  index is negative'''
  if inject_input_idx < 0:
    return None
  else:
    return input_events[inject_input_idx]

def get_following_input(inject_input_idx, input_events):
  ''' Return the event following inject_input_index, or None if
  inject_input_index is the last input '''
  if inject_input_idx < len(input_events) - 1:
    # there is a following input_event
    return input_events[inject_input_idx + 1]
  else:
    return None

def get_expected_internal_events(left_input, right_input, events_list):
  ''' Return previously observed internal events between the left_input and
  the right_input event

  left_input may be None case we return events from the beginning of events_list

  right_input may also be None, in which case we return all events following left_input
  '''
  if left_input is None:
    left_idx = 0
  else:
    left_idx = events_list.index(left_input)

  if right_input is None:
    right_idx = len(events_list)
  else:
    right_idx = events_list.index(right_input)

  return [ i for i in events_list[left_idx:right_idx]
           if isinstance(i, InternalEvent) ]

def play_forward(simulation, inject_input, wait_time_seconds, flush_buffers=False):
  # Directly before the last input has been injected, flush the internal
  # event buffers in case there were unaccounted internal events
  # Note that there isn't a race condition between flush()'ing and
  # incoming internal events, since sts is single-threaded
  # TODO(cs): flush() is no longer needed!
  if flush_buffers:
    simulation.openflow_buffer.flush()
    simulation.controller_sync_callback.flush()

  # Now set all internal event buffers (GodScheduler for
  # ControlMessageReceives and ReplaySyncCallback for state changes)
  # to "pass-through and record"
  simulation.set_pass_through()

  # we inject input after setting pass_through, since some internal
  # events may occur immediately after the input is injected.
  log.info("Injecting input %s" % str(inject_input))
  inject_input.proceed(simulation)

  # Note that this is the monkey patched version of time.sleep
  # TODO(cs): should we subtract the time it took to inject input from
  # wait_time_seconds?
  log.info("peek()'ing for %f seconds" % wait_time_seconds)
  start_time = time.time()
  while time.time() - start_time < wait_time_seconds:
    # Allow through dataplane sends
    for dp_event in simulation.patch_panel.queued_dataplane_events:
      # TODO(cs): record these DataplanePermits rather than enforcing
      # default_dp_permit=True.
      simulation.patch_panel.permit_dp_event(dp_event)
    time.sleep(0.01)

  # Now turn off pass through and grab the inferred events
  newly_inferred_events = simulation.unset_pass_through()
  # Finally, clean up.
  simulation.clean_up()
  log.debug("Recorded %d events" % len(newly_inferred_events))
  return newly_inferred_events

def match_and_filter(newly_inferred_events, expected_internal_events):
  expected_internal_events = [ e for e in expected_internal_events
                               if not isinstance(e, DataplanePermit) ]
  newly_inferred_events = [ e for e in newly_inferred_events
                            if not isinstance(e, DataplanePermit) ]
  log.debug("Matching fingerprints")
  log.info("Expected total: %d" % (len(expected_internal_events)))
  log.info("Inferred total: %d" % (len(newly_inferred_events)))
  if log.getEffectiveLevel() <= logging.DEBUG:
    log.debug("Expected: %s" % (str(expected_internal_events)))
    log.debug("Inferred: %s" % (str(newly_inferred_events)))

  (newly_inferred_events, unmatched_events) = match_fingerprints(newly_inferred_events,
                                                                 expected_internal_events)
  #count_overlapping_fingerprints(newly_inferred_events,
  #                               expected_internal_events)
  # TODO(cs): correct timestamps of unexpected internal events.
  #newly_inferred_events = correct_timestamps(newly_inferred_events,
  #                                           expected_internal_events)

  if log.getEffectiveLevel() <= logging.DEBUG:
    log.debug("Matched events: %s" % (str(newly_inferred_events)))
    log.debug("Unmatched events: %s" % (str(unmatched_events)))

  log.info("Matched events total: %d" % (len(newly_inferred_events)))
  log.info("Unmatched events total: %d" % (len(unmatched_events)))
  return newly_inferred_events

def count_overlapping_fingerprints(newly_inferred_events,
                                   expected_internal_events):
  ''' Track # of instances where an expected event matches 2 or more inferred
  events. Mutates Peeker.ambiguous_counts and Peeker.ambiguous_events'''
  expected_counts = Counter([e.fingerprint for e in expected_internal_events])
  inferred_counts = Counter([e.fingerprint for e in newly_inferred_events])
  total_redundant = 0
  for fingerprint, count in expected_counts.iteritems():
    if fingerprint in inferred_counts and inferred_counts[fingerprint] > count:
      redundant = inferred_counts[fingerprint] - count
      total_redundant += redundant
      # fingerprints[0] is the class name
      Peeker.ambiguous_events[fingerprint[0]] += redundant

  if len(newly_inferred_events) > 0:
    percent_redundant = total_redundant*1.0 / len(newly_inferred_events)
  else:
    percent_redundant = 0.0
  Peeker.ambiguous_counts[percent_redundant] += 1

def deprecated_match_fingerprints(newly_inferred_events, expected_internal_events):
  ''' Deprecated. '''
  # Truncate the newly inferred events based on the expected
  # predecessors of next_input+1
  # inferred_events (and ignore internal events that come afterward)

  # TODO(cs): need to prune any successors of e_i, in case we waited too
  # long

  # Find the last internal event in expected_internal_events that
  # matches an event in newly_inferred_events. That is the new causal
  # parent of following_input
  expected_internal_events.reverse()
  inferred_fingerprints = set([e.fingerprint for e in
                               newly_inferred_events])
  if len(inferred_fingerprints) != len(newly_inferred_events):
    log.warn("Overlapping fingerprints in peek() (%d unique, %d total)" %
             (len(inferred_fingerprints),len(newly_inferred_events)))

  expected_fingerprints = set([e.fingerprint
                               for e in expected_internal_events])
  if len(expected_fingerprints) != len(expected_internal_events):
    log.warn("Overlapping expected fingerprints (%d unique, %d total)" %
             (len(expected_fingerprints),len(expected_internal_events)))

  for expected in expected_internal_events:
    if expected.fingerprint in inferred_fingerprints:
      # We've found our truncation point
      # following_input goes after the expected internal event
      # (we ignore all internal events that come after it)
      # TODO(cs): if the inferred events show up in a different order
      # than the expected events did originally, this algorithm might
      # inadvertently prune expected events (it assumes events are ordered)

      # If there are multiple matching fingerprints, find the instance of
      # the expected fingerprint (e.g., 2nd instance of the expected
      # fingerprint), and match it up with the same instance
      # of the inferred fingerprints
      expected_internal_events = [e for e in expected_internal_events
                                  if e.fingerprint == expected.fingerprint]
      # 1-based indexing of observed instances
      # Note that we are iterating through expected_internal_events in reverse
      # order
      instance_of_expected = len(expected_internal_events)
      observed_instance = 0
      idx_of_last_observed_instance = -1
      parent_index = -1
      for index, event in enumerate(newly_inferred_events):
        if event.fingerprint == expected.fingerprint:
          observed_instance += 1
          idx_of_last_observed_instance = index
          if observed_instance == instance_of_expected:
            parent_index = index
            break

      if parent_index == -1:
        log.warn(('''There were fewer instances of '''
                  '''inferred %s fingerprint than expected %s ''' %
                  (str(newly_inferred_events),str(expected_internal_events))))
        # Set parent_index to the index of the last occurrence
        parent_index = idx_of_last_observed_instance
      newly_inferred_events = newly_inferred_events[:parent_index+1]
      return newly_inferred_events
  # Else, no expected internal event was observed.
  return []

def match_fingerprints(newly_inferred_events, expected_internal_events):
  # TODO(cs): we currently enforce something stronger than
  # happens-before: we enforce a total ordering of events (the serial order
  # recorded in the original trace). I wonder if enforcing a
  # partial ordering would make replay more effective?
  # N.B. expected_internal_events are ordered, whereas newly_inferred_events
  # may not be.
  inferred_fingerprints = Counter([e.fingerprint for e in newly_inferred_events])

  # N.B. to allow unexpected messages through after peek() has finished, set
  # Replayer's "allow_unexpected_messages" parameter.
  ordered_inferred_events = []
  unmatched_events = []
  for e in expected_internal_events:
    if e.fingerprint in inferred_fingerprints:
      ordered_inferred_events.append(e)
      inferred_fingerprints[e.fingerprint] -= 1
      if inferred_fingerprints[e.fingerprint] == 0:
        del inferred_fingerprints[e.fingerprint]
    else:
      unmatched_events.append(e)
  return (ordered_inferred_events, unmatched_events)

def correct_timestamps(new_events, old_events):
  ''' Set new_events' timestamps to approximately the same timestamp as
  old_events.

  Precondition: old_events != []
  '''
  # Lazy strategy: assign all new timestamps to the last timestamp of
  # old_events
  # TODO(cs): match up more carefully, since the timestamps affect how long
  # EventScheduler waits.
  latest_old_ts = old_events[-1].time
  for e in new_events:
    e.time = latest_old_ts
  return new_events


text:
package org.onosproject.incubator.net.faultmanagement.alarm;

import org.onosproject.net.driver.HandlerBehaviour;

import java.util.List;

/**
 * Abstraction of a device behaviour capable of retrieving/consuming list of
 * pending alarms from the device.
 */
public interface AlarmConsumer extends HandlerBehaviour {

    /**
     * Returns the list of active alarms consumed from the device.
     * This means that subsequent retrieval of alarms will not contain
     * any duplicates.
     *
     * @return list of alarms consumed from the device
     */
    List<Alarm> consumeAlarms();

}


text:
The data_decoder service exists to facilitate safe data decoding within an
isolated sandboxed process.


text:
// Code generated by lister-gen. DO NOT EDIT.

package v1alpha1

import (
	v1alpha1 "github.com/libopenstorage/stork/pkg/apis/stork/v1alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// MigrationLister helps list Migrations.
// All objects returned here must be treated as read-only.
type MigrationLister interface {
	// List lists all Migrations in the indexer.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1alpha1.Migration, err error)
	// Migrations returns an object that can list and get Migrations.
	Migrations(namespace string) MigrationNamespaceLister
	MigrationListerExpansion
}

// migrationLister implements the MigrationLister interface.
type migrationLister struct {
	indexer cache.Indexer
}

// NewMigrationLister returns a new MigrationLister.
func NewMigrationLister(indexer cache.Indexer) MigrationLister {
	return &migrationLister{indexer: indexer}
}

// List lists all Migrations in the indexer.
func (s *migrationLister) List(selector labels.Selector) (ret []*v1alpha1.Migration, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha1.Migration))
	})
	return ret, err
}

// Migrations returns an object that can list and get Migrations.
func (s *migrationLister) Migrations(namespace string) MigrationNamespaceLister {
	return migrationNamespaceLister{indexer: s.indexer, namespace: namespace}
}

// MigrationNamespaceLister helps list and get Migrations.
// All objects returned here must be treated as read-only.
type MigrationNamespaceLister interface {
	// List lists all Migrations in the indexer for a given namespace.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1alpha1.Migration, err error)
	// Get retrieves the Migration from the indexer for a given namespace and name.
	// Objects returned here must be treated as read-only.
	Get(name string) (*v1alpha1.Migration, error)
	MigrationNamespaceListerExpansion
}

// migrationNamespaceLister implements the MigrationNamespaceLister
// interface.
type migrationNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

// List lists all Migrations in the indexer for a given namespace.
func (s migrationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Migration, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha1.Migration))
	})
	return ret, err
}

// Get retrieves the Migration from the indexer for a given namespace and name.
func (s migrationNamespaceLister) Get(name string) (*v1alpha1.Migration, error) {
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, errors.NewNotFound(v1alpha1.Resource("migration"), name)
	}
	return obj.(*v1alpha1.Migration), nil
}


text:
# Laravel-Mangopay Integration

This package makes it easier (hopefully!) to integrate the official
[Mangopay SDK](https://github.com/Mangopay/mangopay2-php-sdk) into your Laravel and Lumen applications.

> ## ⚠ This Package Will Be Abandoned
> Due to several factors, including the fact that I no longer use Mangopay,
> I will be ceasing development on this package.  If you are interested in
> taking over this project, please reach out to me here in the Issues board.

[![Build Status](https://travis-ci.org/cviebrock/laravel-mangopay.svg?branch=master&format=flat)](https://travis-ci.org/cviebrock/laravel-mangopay)
[![Total Downloads](https://poser.pugx.org/cviebrock/laravel-mangopay/downloads?format=flat)](https://packagist.org/packages/cviebrock/laravel-mangopay)
[![Latest Stable Version](https://poser.pugx.org/cviebrock/laravel-mangopay/v/stable?format=flat)](https://packagist.org/packages/cviebrock/laravel-mangopay)
[![Latest Unstable Version](https://poser.pugx.org/cviebrock/laravel-mangopay/v/unstable?format=flat)](https://packagist.org/packages/cviebrock/laravel-mangopay)
[![License](https://poser.pugx.org/cviebrock/laravel-mangopay/license?format=flat)](https://packagist.org/packages/cviebrock/laravel-mangopay)

* [Installation](#installation)
  * [Laravel](#laravel)
  * [Lumen](#lumen)
* [Configuration](#configuration)
* [Usage](#usage)
* [Bugs, Suggestions and Contributions](#bugs-suggestions-and-contributions)
* [Copyright and License](#copyright-and-license)

---

## Installation

Depending on your version of Laravel, you should install a different
version of the package. NOTE: As of version 6.0, the package's version
should match the Laravel version.

| Laravel Version | Package Version |
|:---------------:|:---------------:|
|       9.0       |      ^9.0       |
|       8.0       |      ^8.0       |
|       7.0       |      ^7.0       |
|       6.0       |      ^6.0       |
|       5.*       |      ^0.9       |

### Laravel

1. Install the package via composer:

    ```sh
    composer require cviebrock/laravel-mangopay
    ```

    After updating composer, the package will automatically register its
    service provider.

2.  Publish the configuration file:

    ```sh
    php artisan vendor:publish --provider="Cviebrock\LaravelMangopay\ServiceProvider"
    ```

3.  Finally, generate the required temporary directories:

    ```sh
    php artisan mangopay:mkdir
    ```

### Lumen

1. Install the package via composer:

    ```sh
    composer require cviebrock/laravel-mangopay:^6.0
    ```

2.  Copy the configuration file to your `config` folder and enable
    everything in `bootstrap/app.php`:

    ```php
    $app->configure('mangopay');

    $app->register(Cviebrock\LaravelMangopay\ServiceProvider::class);
    ```

3.  Generate the required temporary directories:

    ```sh
    php artisan mangopay:mkdir
    ```

## Configuration

This package supports authentication configuration through the services configuration file located
in `config/services.php`. Add the following block to that file, and set the appropriate
values in your `.env` file:

```php
'mangopay' => [
    'env'    => env('MANGOPAY_ENV', 'sandbox'),  // or "production"
    'key'    => env('MANGOPAY_KEY'),             // your Mangopay client ID
    'secret' => env('MANGOPAY_SECRET'),          // your Mangopay client password
],
```

The configuration file you can publish to `config/mangopay.php` provides additional
properties that can be passed to the MangopayAPI object when it is instantiated.  In
most cases, you won't need to change anything here, so you can choose to not publish this
configuration, or have it simply return an empty array.

If you do use this file, see the SDK documentation for the various properties that can be set
(basically any public property on the `MangoPay\Libraries\Configuration` class).

## Usage

All this package really does is make instantiating the `MangopayAPI` easy by
putting the configuration into Laravel/Lumen's config system.

Using it is now as easy as injecting Mangopay into your controller, and then
using it the same way you would use the `MangopayAPI` class:

```php
class MyController extends Illuminate\Routing\Controller
{

    /**
     * @var \MangoPay\MangoPayApi
     */
    private $mangopay;

    public function __construct(\MangoPay\MangoPayApi $mangopay) {
        $this->mangopay = $mangopay;
    }

    public function doStuff($someId)
    {
        // get some user by id
        $john = $this->mangopay->Users->Get($someId);

        // change and update some of his data
        $john->LastName .= " - CHANGED";
        $this->mangopay->Users->Update($john);

        // get his bank accounts
        $pagination = new MangoPay\Pagination(1, 10); // get 1st page, 10 items per page
        $accounts = $this->mangopay->Users->GetBankAccounts($john->Id, $pagination);

        // etc.
    }
}
```

## Bugs, Suggestions and Contributions

Thanks to [everyone](/cviebrock/laravel-mangopay/graphs/contributors) who has contributed
to this project!   Special thanks to
[JetBrains](https://www.jetbrains.com/?from=cviebrock/laravel-mangopay) for their
Open Source License Program ... and the excellent PHPStorm IDE, of course!

[![JetBrains](./.github/jetbrains.svg)](https://www.jetbrains.com/?from=cviebrock/laravel-mangopay)

Please use [Github](https://github.com/cviebrock/laravel-mangopay) for reporting bugs,
and making comments or suggestions.

See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute changes.

## Copyright and License

laravel-mangopay was written by Colin Viebrock and released under the MIT License.
See [LICENSE.md](LICENSE.md) file for details.

Copyright (c) 2016 Colin Viebrock


text:
START_ATF_NAMESPACE
    struct BASE_HACKSHEILD_PARAM
    {
        BASE_HACKSHEILD_PARAMVtbl *vfptr;
    public:
        BASE_HACKSHEILD_PARAM();
        void ctor_BASE_HACKSHEILD_PARAM();
    };
END_ATF_NAMESPACE


text:
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>

<link href="doc-style.css" type="text/css" rel="StyleSheet">

		Local Properties

Managed Object Types	Data Object Types	All Properties	All Methods

Data Object - LocalizationManagerMessageCatalog

Property of

LocalizationManager

Extends

DynamicData

Since

vSphere API 4.0

Data Object
                  Description

         Description of an available message catalog

Properties

	          Name

	          Type

	          Description

catalogName	xsd:string

         The name of the catalog.

catalogUri	xsd:string

         The URI (relative to the connection URL for the VirtualCenter server
 itself) from which the catalog can be downloaded.

 The caller will need to augment this with a scheme and authority (host
 and port) to make a complete URL.

lastModified*	xsd:dateTime

         The last-modified time of the catalog file, if available

locale	xsd:string

         The locale for the catalog.

md5sum*	xsd:string

         The checksum of the catalog file, if available

moduleName	xsd:string

         The module or extension that publishes this catalog.

 The moduleName will be empty for the core catalogs for the
 VirtualCenter server itself.

version*	xsd:string

         The version of the catalog file, if available

 The format is dot-separated version string, e.g. "1.2.3".

Since vSphere API 5.0

						Properties inherited from DynamicData

dynamicProperty, dynamicType

*Need not be set

Show WSDL type definition

<textarea cols="20" rows="10" name="wsdl-textarea" wrap="off" readonly="1" id="wsdl-textarea">         <complexType xmlns="http://www.w3.org/2001/XMLSchema" xmlns:vim25="urn:vim25" name="LocalizationManagerMessageCatalog">
            <complexContent>
               <extension base="vim25:DynamicData">
                  <sequence>
                     <element name="moduleName" type="xsd:string"/>
                     <element name="catalogName" type="xsd:string"/>
                     <element name="locale" type="xsd:string"/>
                     <element name="catalogUri" type="xsd:string"/>
                     <element name="lastModified" type="xsd:dateTime" minOccurs="0"/>
                     <element name="md5sum" type="xsd:string" minOccurs="0"/>
                     <element name="version" type="xsd:string" minOccurs="0"/>
                  </sequence>
               </extension>
            </complexContent>
         </complexType></textarea>

Top of page		Local Properties

Managed Object Types	Data Object Types	All Properties	All Methods


text:
package ar.com.larreta.mystic.model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import org.hibernate.annotations.Where;
import org.springframework.beans.factory.annotation.Autowired;

import ar.com.larreta.tools.BeanUtils;
import ar.com.larreta.tools.SpringUtils;

@MappedSuperclass
@Where(clause=Entity.NOT_DELETED)
public class Entity implements Serializable {

	public static final String NOT_DELETED = "deleted IS NULL";
	public static final String ID = "id";

	protected Long id;
	protected Date deleted;

	@Autowired
	private BeanUtils beanUtils;

	@Id
	@GeneratedValue
	public Long getId(){
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Basic
	public Date getDeleted(){
		return deleted;
	}

	public void setDeleted(Date deleted) {
		this.deleted = deleted;
	}

	@Override
	public boolean equals(Object object) {
		if (object!=null) {
			Entity entity = (Entity) object;
			return entity.getId().equals(getId());
		}
		return Boolean.FALSE;
	}

	@Override
	public int hashCode() {
		if (getId()==null){
			return super.hashCode();
		}
		return getId().hashCode();
	}

	/**
	 * Util para redefinir el tipo de entidad a utilizar durante la persistencia
	 * Si es null asume que el tipo de entidad es el definido en el encabezado de la clase
	 */
	@Transient
	public String getPersistEntityName(){
		return null;
	}

	protected void writeToAll(Collection source, String property, Serializable value){
		if (beanUtils==null){
			beanUtils = (BeanUtils) SpringUtils.getBean(BeanUtils.class);
		}
		beanUtils.writeToAll(source, property, value);
	}

}


text:
:: Requires Python 3.7
call python -m pip install --upgrade pip setuptools
call python -m pip install --user virtualenv
call python -m venv ./env

call .\upgradeinstall.bat


text:
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('entries', '0008_auto_20161208_0107'),
    ]

    operations = [
        migrations.AddField(
            model_name='entry',
            name='user',
            field=models.OneToOneField(default=None, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
            preserve_default=False,
        ),
    ]


text:
.. scriptine documentation master file, created by
   sphinx-quickstart on Wed Jul 29 11:57:44 2009.

Welcome to scriptine's documentation!
=====================================

.. toctree::
   :maxdepth: 2

   intro
   modules

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`


text:
$(document).ready(function() {

	// perfBar.init();

	// Initialize Foundation JS
	$(document).foundation();

	var init = function() {
		Parse.initialize("iWHUm91rCzR2LTMzPptACdSLhtHZL4KJmvBwPY8N",
										 "1MMjDeyiHi3WLasr0S0Mo0KihKnFEtsIvoU1VMrX");
		// Check if the user is logged in
		if(Parse.User.current()) {
			getGifts();
		} else {
			loginSignUp();
		}
	}

	var loginSignUp = function() {
		$('#main-content').html('');
		this.template = Handlebars.compile($('#login-signup').html());
		$('#main-content').append(template());
	}

	var login = function() {
		this.username = $('#login-username').val();
		this.password = $('#login-password').val();

		Parse.User.logIn(this.username, this.password, {
			success: function() {
				console.log('User logged in!');
				init();
			},
			error: function(user, error) {
				console.log(user);
				console.log("Error: " + error.code + " " + error.message);
				$('.login-error').html(error.message).fadeIn().css('display', 'inline-block');
			}
		});
	}

	var logout = function() {
		Parse.User.logOut();
		init();
	}

	var signUp = function() {
		this.user = new Parse.User();
		this.username = $('#signup-username').val();
		this.password = $('#signup-password').val();
		this.email = $('#signup-email').val();

		user.signUp({
			'username': this.username,
			'password': this.password,
			'email': this.email
		}, {
			success: function() {
				console.log('User created!');
				getGifts();
			},
			error: function(user, error) {
				console.log("Error: " + error.code + " " + error.message);
				$('.signup-error').html(error.message).fadeIn().css('display', 'inline-block');
			}
		});
	}

	var saveGift = function() {
		this.user = Parse.User.current();
		this.Gift = Parse.Object.extend('Gift');
		this.gift = new Gift();

		gift.save({
		 'giftName': $('#gift-name').val(),
		 'giftPrice': $('#gift-price').val(),
		 'giftStore': $('#gift-store').val(),
		 'giftQuantity': $('#gift-quantity').val(),
		 'giftLink': $('#gift-link').val(),
		 'giftDescription': $('#gift-description').val(),
		 'user': this.user
		}, {
			success: function() {
				console.log('Gift saved!');
				$('#gift-name, #gift-price, #gift-store, #gift-quantity, #gift-link, #gift-description').val('');
				getGifts();
			},
			error: function(gift, error) {
				console.log("Error: " + error.code + " " + error.message);
			}
		});
	}

	var addGift = function(el) {
		$('#gift-form').html('');
		this.template = Handlebars.compile($('#add-gift').html());
		$('#gift-form').html(template());
	}

	var editGift = function(el) {
		this.Gift = Parse.Object.extend('Gift');
		this.query = new Parse.Query(Gift);
		this.id = $(el).attr('data-id');

		query.get(this.id, {
			success: function(gift) {
				var json = gift.toJSON();

				$('#gift-form').html('');
				this.template = Handlebars.compile($('#edit-gift').html());
				$('#gift-form').html(template(json));
			},
			error: function(gift, error) {
				console.log("Error: " + error.code + " " + error.message);
			}
		});
	}

	var deleteGift = function(el) {
		this.Gift = Parse.Object.extend('Gift');
		this.query = new Parse.Query(Gift);
		this.id = $(el).attr('data-id');

		query.get(this.id, {
			success: function(gift) {
				gift.destroy({
					success: function(gift) {
						console.log('Gift deleted!');
						getGifts();
					},
					error: function(gift, error) {
						console.log("Error: " + error.code + " " + error.message);
					}
				})
			},
			error: function(gift, error) {
				console.log("Error: " + error.code + " " + error.message);
			}
		});
	}

	var updateGift = function(el) {
		this.Gift = Parse.Object.extend('Gift');
		this.query = new Parse.Query(Gift);
		this.id = $(el).attr('data-id');

		query.get(this.id, {
			success: function(gift) {
				gift.save({
				 'giftName': $('#gift-name').val(),
				 'giftPrice': $('#gift-price').val(),
				 'giftStore': $('#gift-store').val(),
				 'giftQuantity': $('#gift-quantity').val(),
				 'giftLink': $('#gift-link').val(),
				 'giftDescription': $('#gift-description').val()
				}, {
					success: function(gift) {
						console.log('Gift updated!');
						init();
					},
					error: function(gift, error) {
						console.log("Error: " + error.code + " " + error.message);
					}
				})
			},
			error: function(gift, error) {
				console.log("Error: " + error.code + " " + error.message);
			}
		});
	}

	var getGifts = function() {
		this.user = Parse.User.current();
		this.Gift = Parse.Object.extend('Gift');
		this.query = new Parse.Query(Gift);
		query.descending('createdAt');
		query.limit(25);
		query.equalTo('user', user);

		query.find({
			success: function(results) {
				var user_info = user.toJSON();

				$('#main-content').html('');
				this.template = Handlebars.compile($('#gift-list').html());
				$('#main-content').html(template(user_info));

				this.template = Handlebars.compile($('#single-gift').html());

				$(results).each(function(i,el) {
					var json = el.toJSON();
					$('#gift-list').append(template(json));
				});

				if(results.length == 0) {
					$('#gift-list').append('
Looks like you haven\'t added any gifts yet.
');
				}

			},
			error: function(error) {
				console.log("Error: " + error.code + " " + error.message);
			}
		});
	}

	$('body').on('click', '#login-btn', function(e) {
		e.preventDefault();
		if($('#login-username').val() && $('#login-password').val()) {
			login();
		} else {
			$('.login-error').html('All the fields must be filled out').fadeIn().css('display', 'inline-block');
		}
	});

	$('body').on('click', '#signup-btn', function(e) {
		e.preventDefault();
		if($('#signup-username').val() && $('#signup-password').val() && $('#signup-email').val()) {
			signUp();
		} else {
			$('.signup-error').html('All the fields must be filled out').fadeIn().css('display', 'inline-block');
		}
	});

	$('body').on('click', '#add-gift-btn', function(e) {
		e.preventDefault();
		if($('#gift-name').val() && $('#gift-price').val() && $('#gift-store').val() && $('#gift-quantity').val()) {
			saveGift();
		} else {
			$('.error').html('Name, price, store, and quantity are required.').fadeIn().css('display', 'inline-block');
		}
	});

	$('body').on('click', '#update-gift-btn', function(e) {
		e.preventDefault();
		if($('#gift-name').val() && $('#gift-price').val() && $('#gift-store').val() && $('#gift-quantity').val()) {
			updateGift(this);
		} else {
			$('.error').html('Name, price, store, and quantity are required.').fadeIn().css('display', 'inline-block');
		}
	});

	$('body').on('click', '.single-gift a.delete-prompt-btn', function(e) {
		e.preventDefault();
		var id = $(this).attr('data-id');
		$(this).parent('.actions').html('
Are you sure you want to delete this gift? Yes | No
').hide().fadeIn();
	});

	$('body').on('click', 'a.add-new-gift-btn', function(e) {
		e.preventDefault();
		addGift();
		$('.gift-form-modal').trigger('click');
	});

	$('body').on('click', '.single-gift a.edit-gift-btn', function(e) {
		e.preventDefault();
		editGift(this);
		$('.gift-form-modal').trigger('click');
	});

	$('body').on('click', '.single-gift a.delete-gift-btn', function(e) {
		e.preventDefault();
		deleteGift(this);
	});

	$('body').on('click', '.cancel-change', function(e) {
		e.preventDefault();
		init();
	});

	$('body').on('click', '#logout', function(e) {
		e.preventDefault();
		logout();
	});

	init();

});


text:
(function($) {
	var defaults = {
		container : '#container', //容器
		sections : '.section', //子容器
		easing : 'ease', //特效方式
		duration : 500 ,//每次动画执行的时间
		tapCallBack : null ,//点击事件的回调函数
		switchEndCallBack : null //滑动结束后的回调函数
	};
	var win = $(window),
		container, sections , up;
	var opts = {},
		canScroll = true,
		iIndex = 0,
		arrElement = [];
	var timeScroll; //滚动间隔定时器
	var SP = $.fn.switchPage = function(options) {
		opts = $.extend({}, defaults, options || {});
		container = $(opts.container);
		sections = container.find(opts.sections);
		sections.each(function() {
			arrElement.push($(this));
		});
		return this.each(function() {
			var start = {x:0 , y:0},
				end = {x:0 , y:0};
			document.body.addEventListener('touchstart', function (event) {
				var touch = event.targetTouches[0];
				start.x = touch.pageX;
				start.y = touch.pageY;
				end.x = touch.pageX;
				end.y = touch.pageY;
			},false);
			document.body.addEventListener('touchmove', function (event) {
				event.preventDefault();
				var touch = event.targetTouches[0];
				end.x = touch.pageX;
				end.y = touch.pageY;
			},false);
			document.body.addEventListener('touchend', function () {
				event.preventDefault();
				if(!canScroll) return;
				if(start.y - end.y > 30){
					SP.moveSectionDown();
				}else if(end.y - start.y > 30){
					SP.moveSectionUp();
				}
				start = {x:0 , y:0};
				end = {x:0 , y:0};
			},false);
			//窗口Resize
			var resizeId;
			win.resize(function() {
				clearTimeout(resizeId);
				resizeId = setTimeout(function() {
					reBuild();
				}, 500);
			});
			//点击事件
			if(opts.tapCallBack && typeof opts.tapCallBack === "function"){
				$("body").on("tap" , function(){
					opts.tapCallBack(iIndex);
				})
			}
			//动画
			container.css({
				"-webkit-transition": "all " + opts.duration + "ms " + opts.easing,
				"transition": "all " + opts.duration + "ms " + opts.easing
			});
		});
	};
	//滚轮向上滑动事件
	SP.moveSectionUp = function() {
		if (iIndex) {
			iIndex--;
			scrollPage(arrElement[iIndex]);
		}
	};
	//滚轮向下滑动事件
	SP.moveSectionDown = function() {
		if (iIndex < (arrElement.length - 1)) {
			iIndex++;
			scrollPage(arrElement[iIndex]);
		}
	};
	//页面滚动事件
	function scrollPage(element) {
		var dest = element.position();
		if (typeof dest === 'undefined') {
			return;
		}
		initEffects(dest, element);
	}
	//渲染效果
	function initEffects(dest, element) {
		var endFun = function(){
			canScroll = true;
			if(opts.switchEndCallBack && typeof opts.switchEndCallBack === "function"){
				opts.switchEndCallBack(iIndex);
			}
		};
		canScroll = false;
		var traslate = "0px, -" + dest.top + "px";
		container.css({
			"-webkit-transform": "translate(" + traslate + ")",
			"transform": "translate(" + traslate + ")"
		});
		// 一定时间间隔后,允许第二次滚动
		clearTimeout(timeScroll);
		timeScroll = setTimeout(function() {
			endFun();
		}, opts.duration);
	}
	//屏幕大小变动后调用
	function reBuild() {
		var currentHeight = win.height(),
			currentWidth = win.width();
		var element = arrElement[iIndex];
		var offsetTop = element.offset().top;
		if (Math.abs(offsetTop) > currentHeight / 2 && iIndex < (arrElement.length - 1)) {
			iIndex++;
		}
		if (iIndex) {
			var cuerrentElement = arrElement[iIndex],
				dest = cuerrentElement.position();
			initEffects(dest, cuerrentElement);
		}
	}
})($);
(function(window,undefind){	//图片加载控件
	function imgLoad(options){
		var defaults = {
			imgArr : [],		//图片数组
			loadOverCallback : null		//加载完成的回调函数
		};
		var opts = $.extend(true , defaults , options || {}),
			imgSize = opts.imgArr.length, //需要加载图片的个数
			completeSize = 0;
		function beginLoad() {
			for (var index in opts.imgArr) {
				var src = opts.imgArr[index];
				src && loadImg(src);
			}
		}
		function loadImg(src) {		//加载图片
			var image = new Image(),
				handleLoadOver = function() {
					completeSize++;
					checkLoadOver();
				};
			image.src = src;
			if (image.complete) { //图片有缓存
				handleLoadOver();
			} else {
				image.onload = function() { //图片获取成功
					handleLoadOver();
				};
			}
		}
		function checkLoadOver() {	//查询是否已经加载完毕
			if (completeSize != imgSize) return;
			if(opts.loadOverCallback && typeof opts.loadOverCallback === "function"){
				opts.loadOverCallback();
			}
		}
		beginLoad()//开始执行
	}
	window.imgLoad = imgLoad;
})(window);