SquareSet extension type
A finite set of all squares on a chessboard.
All the squares are represented by a single 64-bit integer, where each bit corresponds to a square, using a little-endian rank-file mapping. See also Square.
The set operations are implemented as bitwise operations on the integer.
- on
Constructors
- SquareSet(int value)
-
const
- SquareSet.backrankOf(Side side)
-
Create a SquareSet containing all squares of the given backrank Side.
const
- SquareSet.fromFile(File file)
-
Create a SquareSet containing all squares of the given file.
const
- SquareSet.fromRank(Rank rank)
-
Create a SquareSet containing all squares of the given rank.
const
- SquareSet.fromSquare(Square square)
-
Creates a SquareSet with a single Square.
const
-
SquareSet.fromSquares(Iterable<
Square> squares) - Creates a SquareSet from several Squares.
Properties
- first → Square?
-
Returns the first square in the set, or null if the set is empty.
no setter
- isEmpty → bool
-
Returns true if the set is empty.
no setter
- isNotEmpty → bool
-
Returns true if the set is not empty.
no setter
- last → Square?
-
Returns the last square in the set, or null if the set is empty.
no setter
- moreThanOne → bool
-
Returns true if the set contains more than one square.
no setter
- singleSquare → Square?
-
Returns square if it is single, otherwise returns null.
no setter
- size → int
-
Returns the number of squares in the set.
no setter
-
squares
→ Iterable<
Square> -
Returns the squares in the set as an iterable.
no setter
-
squaresReversed
→ Iterable<
Square> -
Returns the squares in the set as an iterable in reverse order.
no setter
- value → int
-
final
Methods
-
complement(
) → SquareSet - Returns the set complement of this set.
-
diff(
SquareSet other) → SquareSet -
Returns the set difference of this set and
other. -
flipVertical(
) → SquareSet - Flips the set vertically.
-
has(
Square square) → bool -
Returns true if the SquareSet contains the given
square. -
intersect(
SquareSet other) → SquareSet -
Returns a new SquareSet with the squares that are in both this set and
other. -
isDisjoint(
SquareSet other) → bool -
Returns true if the square set is disjoint from the
othersquare set. -
isIntersected(
SquareSet other) → bool -
Returns true if the square set has any square in the
othersquare set. -
minus(
SquareSet other) → SquareSet -
Returns a new SquareSet with the
othersquares removed from this set. -
mirrorHorizontal(
) → SquareSet - Flips the set horizontally.
-
shl(
int shift) → SquareSet - Bitwise left shift
-
shr(
int shift) → SquareSet - Bitwise right shift
-
toggleSquare(
Square square) → SquareSet - Removes Square if present, or put it if absent.
-
toHexString(
) → String - Returns the hexadecimal string representation of the bitboard value.
-
union(
SquareSet other) → SquareSet -
Returns a new SquareSet with the squares that are in either this set or
other. -
withoutFirst(
) → SquareSet - Returns a new SquareSet with its first Square removed.
-
withoutSquare(
Square square) → SquareSet -
Returns a new SquareSet with the given
squareremoved. -
withSquare(
Square square) → SquareSet -
Returns a new SquareSet with the given
squareadded. -
xor(
SquareSet other) → SquareSet -
Returns a new SquareSet with a bitwise XOR of this set and
other.
Operators
-
operator &(
SquareSet other) → SquareSet -
operator -(
SquareSet other) → SquareSet -
operator ^(
SquareSet other) → SquareSet -
operator |(
SquareSet other) → SquareSet
Constants
- aFile → const SquareSet
- antidiagonal → const SquareSet
- backranks → const SquareSet
- center → const SquareSet
- corners → const SquareSet
- darkSquares → const SquareSet
- diagonal → const SquareSet
- eighthRank → const SquareSet
- empty → const SquareSet
- firstRank → const SquareSet
- full → const SquareSet
- hFile → const SquareSet
- lightSquares → const SquareSet