/*
 *      Copyright (c) 2023, an unpublished work by CodeSecure, Inc.
 *                      ALL RIGHTS RESERVED
 *
 *      Copyright (c) 2005-2023, an unpublished work by GrammaTech, Inc.
 *                      ALL RIGHTS RESERVED
 *
 *      This software is furnished under a license and may be used and
 *      copied only in accordance with the terms of such license and the       
 *      inclusion of the above copyright notice.  This software or any
 *      other copies thereof may not be provided or otherwise made
 *      available to any other person.  Title to and ownership of the
 *      software is retained by CodeSecure, Inc.
 */

#include <stdlib.h>
#include <stdio.h>
#include "my_iterator.h"


int checked(it *my_it){
  if (! my_iterator_IsValid(my_it)) return -1;
  return my_iterator_GetVal(my_it);
}

int not_checked(it *my_it){
  return my_iterator_GetVal(my_it);
}

int main(int argc, char *argv[]){

    it *my_it = my_iterator_New();
    int m = -1;
    int k;

    if (my_it != NULL){

        my_iterator_Init(my_it);
        my_iterator_SetVal(my_it,5);
        k = my_iterator_Next(my_it);

        if (!k) {  my_iterator_Dispose(my_it); return 1;}

        if (rand() > 5){
            m = checked(my_it); 
        }
        else {
            m = not_checked(my_it);      
        }

        printf("m = %d \n", m);
        my_iterator_Dispose(my_it);

    }
    return 0;
}



