Add clear() to SizedArray

Change-Id: I237c344378ecf4966e12fb2aee6975696909e178
diff --git a/aos/containers/sized_array.h b/aos/containers/sized_array.h
index 6d4209a..34e9206 100644
--- a/aos/containers/sized_array.h
+++ b/aos/containers/sized_array.h
@@ -109,6 +109,8 @@
     --size_;
   }
 
+  void clear() { size_ = 0; }
+
   // These allow access to the underlying storage. The data here may be outside
   // the current logical extents of the container.
   const array &backing_array() const { return array_; }
diff --git a/aos/containers/sized_array_test.cc b/aos/containers/sized_array_test.cc
index 04a8e41..bfaba06 100644
--- a/aos/containers/sized_array_test.cc
+++ b/aos/containers/sized_array_test.cc
@@ -135,5 +135,24 @@
   }
 }
 
+// Tests various ways of filling up and emptying.
+TEST(SizedArrayTest, FillEmpty) {
+  SizedArray<int, 2> a;
+  EXPECT_TRUE(a.empty());
+  EXPECT_FALSE(a.full());
+  a.push_back(9);
+  EXPECT_FALSE(a.empty());
+  EXPECT_FALSE(a.full());
+  a.push_back(7);
+  EXPECT_FALSE(a.empty());
+  EXPECT_TRUE(a.full());
+
+  a.clear();
+  EXPECT_TRUE(a.empty());
+  EXPECT_FALSE(a.full());
+  a.push_back(1);
+  EXPECT_EQ(1, a.back());
+}
+
 }  // namespace testing
 }  // namespace aos