Add Ord instances.

This commit is contained in:
Sébastien Crozet 2013-06-15 18:06:13 +00:00
parent 3ccade3d2f
commit 6e627f3378
6 changed files with 15 additions and 15 deletions

View File

@ -10,7 +10,7 @@ use traits::sub_dot::SubDot;
use traits::flatten::Flatten;
use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub};
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct Vec1<N>
{ x : N }
@ -171,7 +171,7 @@ impl<N:Copy + Zero> Zero for Vec1<N>
impl<N: Copy + One> Basis for Vec1<N>
{
#[inline(always)]
fn canonical_basis() -> ~[Vec1<N>]
fn canonical_basis() -> ~[Vec1<N>]
{ ~[ Vec1::new(One::one()) ] } // FIXME: this should be static
#[inline(always)]
@ -194,7 +194,7 @@ impl<N:ApproxEq<N>> ApproxEq<N> for Vec1<N>
{ self.x.approx_eq_eps(&other.x, epsilon) }
}
impl<N:Rand + Copy> Rand for Vec1<N>
impl<N: Rand + Copy> Rand for Vec1<N>
{
#[inline(always)]
fn rand<R: Rng>(rng: &mut R) -> Vec1<N>

View File

@ -12,7 +12,7 @@ use traits::flatten::Flatten;
use traits::translation::Translation;
use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub};
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct Vec2<N>
{
x : N,

View File

@ -11,7 +11,7 @@ use traits::flatten::Flatten;
use traits::translation::Translation;
use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub};
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct Vec3<N>
{
x : N,

View File

@ -11,7 +11,7 @@ use traits::norm::Norm;
use traits::translation::Translation;
use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub};
#[deriving(Eq, ToStr, Clone)]
#[deriving(Eq, Ord, ToStr, Clone)]
pub struct DVec<N>
{
at: ~[N]

View File

@ -21,7 +21,7 @@ use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub}
// using d0, d1, d2, d3, ..., d7 (or your own dn) are prefered.
// FIXME: it might be possible to implement type-level integers and use them
// here?
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct NVec<D, N>
{ at: DVec<N> }

View File

@ -11,42 +11,42 @@ pub trait Dim {
/// Dimensional token for 0-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct d0;
/// Dimensional token for 1-dimension. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct d1;
/// Dimensional token for 2-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct d2;
/// Dimensional token for 3-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct d3;
/// Dimensional token for 4-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct d4;
/// Dimensional token for 5-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct d5;
/// Dimensional token for 6-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct d6;
/// Dimensional token for 7-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
#[deriving(Eq, ToStr)]
#[deriving(Eq, Ord, ToStr)]
pub struct d7;
impl Dim for d0