def run(item_list):
  import sys
  sys.stdout.write("\nRUNNING: {}\n".format(' '.join(item_list)))
  q = ResizingArrayQueue()
  for item in item_list:
    if item != "-": q.enqueue(item)
    else: sys.stdout.write("  DEQUEUE: {}\n".format(q.dequeue()))
  sys.stdout.write("({} left on queue): {}\n".format(q.size(), q))


if __name__ == '__main__':
  import InputArgs as IA
  import sys
  # If user did not provide a sequence.
  if len(sys.argv) == 1:
    run( IA.get_seq__int_or_str("a b c d - - e f - - g h i -") )
    run( IA.get_seq__int_or_str("a - b - c d - - e f - - g h i -") )
  # If user provided a sequence in the runtime arguments.
  else:
    run( IA.get_list_from_args() )

###########################################################################
# Lecture Week 2 Generics (9:26)
###########################################################################
# -------------------------------------------------------------------------
# BAD: Before Java 1.5 (2004-09-29) 
# GRRRR JAVA(<1.5 2004), NO GENERIC SUPPORT = Separate container class for every type.

# 02:00 BAD: Casting in client code:
# 
#    StackOfObjects s = new StackOfObjects();
Example #2
0
def default_examples():
  import InputArgs as IA
  bag = run( IA.get_seq__int_or_str("1 2 3 4 5 6 7 8 9") )
Example #3
0
def run(seqstr):
  import InputArgs as IA
  return run_list( IA.get_seq__int_or_str(seqstr) )