blob: c2f299032fd18fe9e41a8c3f14600e774e3f4ed4 [file] [log] [blame]
// Copied from source at github.com/kseo/tuple/blob/470ed3aeb/lib/src/tuple.dart
// Original copyright:
// Copyright (c) 2014, the tuple project authors. Please see the AUTHORS
// file for details. All rights reserved. Use of this source code is governed
// by a BSD-style license that can be found in the LICENSE file.
/// Represents a 2-tuple, or pair.
class Tuple2<T1, T2> {
/// Returns the first item of the tuple
final T1 item1;
/// Returns the second item of the tuple
final T2 item2;
/// Creates a new tuple value with the specified items.
const Tuple2(this.item1, this.item2);
@override
String toString() => '[$item1, $item2]';
@override
bool operator ==(Object other) =>
other is Tuple2 && other.item1 == item1 && other.item2 == item2;
@override
int get hashCode => Object.hash(item1, item2);
}
/// Represents a 3-tuple, or triple.
class Tuple3<T1, T2, T3> {
/// Returns the first item of the tuple
final T1 item1;
/// Returns the second item of the tuple
final T2 item2;
/// Returns the third item of the tuple
final T3 item3;
/// Creates a new tuple value with the specified items.
const Tuple3(this.item1, this.item2, this.item3);
@override
String toString() => '[$item1, $item2, $item3]';
@override
bool operator ==(Object other) =>
other is Tuple3 &&
other.item1 == item1 &&
other.item2 == item2 &&
other.item3 == item3;
@override
int get hashCode => Object.hash(item1, item2, item3);
}