提交 12e506fd 编写于 作者: B Behdad Esfahbod

[iter] Add hb_fill()

上级 ad3ed58d
...@@ -44,16 +44,23 @@ struct array_iter_t : hb_iter_t<array_iter_t<T>, T> ...@@ -44,16 +44,23 @@ struct array_iter_t : hb_iter_t<array_iter_t<T>, T>
hb_array_t<T> arr; hb_array_t<T> arr;
}; };
template <typename S, typename D> static inline bool template <typename C, typename V> inline void
copy (D &d, hb_iter_t<S> &s) hb_fill (const C &c, const V &v)
{
for (typename C::iter_t i = c.iter (); i; i++)
hb_assign (*i, v);
}
template <typename S, typename D> inline bool
hb_copy (const D &d, const S &s)
{ {
typename S::iter_t is = s.iter (); typename S::iter_t is = s.iter ();
typename D::iter_t id = d.iter (); typename D::iter_t id = d.iter ();
for (; d && s; ++d, ++s) for (; id && is; ++id, ++is)
*d = *s; *id = *is;
return !d; return !id;
} }
int int
...@@ -69,7 +76,8 @@ main (int argc, char **argv) ...@@ -69,7 +76,8 @@ main (int argc, char **argv)
s2 = s; s2 = s;
copy (t, s); hb_fill (t, 42);
hb_copy (t, s);
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册