Updated QueueWithArray to use generics and implement Iterable