add list first, last, foreach_reverse, and foreach_reverse_safe APIs

Reviewer: @harshsin