class ReversedListIterator<T> implements ReversibleIterator<T> {
        final private @NotNull List<T> list;
        final private boolean isReversed;
        private int index;

        ReversedListIterator(@NotNull List<T> list, boolean isReversed) {
            this.list = list;
            this.isReversed = isReversed;
            if (isReversed) {
                this.index = list.size() == 0 ? -1 : list.size() - 1;
            } else {
                this.index = list.size() == 0 ? -1 : 0;
            }
        }

        @Override
        public boolean isReversed() {
            return isReversed;
        }

        @Override
        public void remove() {

        }

        @Override
        public boolean hasNext() {
            return index != -1;
        }

        @Override
        public T next() {<FILL_FUNCTION_BODY>}
    }

            T t = list.get(index);
            if (index != -1) {
                if (isReversed) {
                    index--;
                } else {
                    if (index == list.size() - 1) {
                        index = -1;
                    } else {
                        index++;
                    }
                }
            }

            return t;
        
<no_super_class>