make some methods on ArrayNx1 more generic (Array)
@@ -172,27 +172,50 @@ impl<N, Chan> Array<N, Chan> {
}
}
-impl<N, T, Store> ArrayNx1<N, T, Store>
+impl<N, Chan> IndexedArray<N> for Array<N, Chan>
where
- PointN<N>: IntegerPoint<N>,
- Store: Deref<Target = [T]>,
+ N: ArrayIndexer<N>,
{
- pub fn new_one_channel(extent: ExtentN<N>, values: Store) -> Self {
- assert_eq!(extent.num_points(), values.len());
+ type Indexer = N;
- Self::new(extent, Channel::new(values))
+ #[inline]
+ fn extent(&self) -> &ExtentN<N> {
+ self.extent()
}
}
-impl<N, Chan> IndexedArray<N> for Array<N, Chan>
+impl<N, Chan> Array<N, Chan>
where
- N: ArrayIndexer<N>,
+ PointN<N>: IntegerPoint<N>,
{
- type Indexer = N;
+ /// Sets the extent minimum to `p`.
+ #[inline]
+ pub fn set_minimum(&mut self, p: PointN<N>) {
+ self.extent.minimum = p;
+ }
+ /// Adds `p` to the extent minimum.
#[inline]
- fn extent(&self) -> &ExtentN<N> {
- self.extent()
+ pub fn translate(&mut self, p: PointN<N>) {
+ self.extent = self.extent.add(p);
+ }
+
+ /// Returns `true` iff this map contains point `p`.
+ #[inline]
+ pub fn contains(&self, p: PointN<N>) -> bool {
+ self.extent.contains(p)
+ }
+}
+
+impl<N, T, Store> ArrayNx1<N, T, Store>
+where
+ PointN<N>: IntegerPoint<N>,
+ Store: Deref<Target = [T]>,
+{
+ pub fn new_one_channel(extent: ExtentN<N>, values: Store) -> Self {
+ assert_eq!(extent.num_points(), values.len());
+
+ Self::new(extent, Channel::new(values))
}
}
@@ -250,35 +273,6 @@ where
}
}
-impl<N, T, Store> ArrayNx1<N, T, Store>
-where
- PointN<N>: IntegerPoint<N>,
- Store: Deref<Target = [T]>,
-{
- /// Sets the extent minimum to `p`.
- #[inline]
- pub fn set_minimum(&mut self, p: PointN<N>) {
- self.extent.minimum = p;
- }
-
- /// Adds `p` to the extent minimum.
- #[inline]
- pub fn translate(&mut self, p: PointN<N>) {
- self.extent = self.extent.add(p);
- }
-}
-
-impl<N, T, Store> ArrayNx1<N, T, Store>
-where
- PointN<N>: Point,
-{
- /// Returns `true` iff this map contains point `p`.
- #[inline]
- pub fn contains(&self, p: PointN<N>) -> bool {
- self.extent.contains(p)
- }
-}
-
impl<N, T, Store> ArrayNx1<N, T, Store>
where
for<'r> Self: ForEachMut<'r, N, (), Item = &'r mut T>,
