001 package rac;
002 import lrs.*;
003
004 /**
005 * LIFO RAC.
006 * @author Mathias Ricken - Copyright 2008 - All rights reserved.
007 */
008 public class LRSStackFactory<T> extends ALRSRACFactory<T> {
009 /**
010 * Create a ``last-in, first-out'' (LIFO) container.
011 */
012 public IRAContainer<T> makeRAC() {
013 return new LRSRAContainer<T>(new IAlgo<T,LRStruct<T>,T>() {
014 public LRStruct<T> emptyCase(LRStruct<T> host, T... input) {
015 return host.insertFront(input[0]);
016 }
017
018 public LRStruct<T> nonEmptyCase(LRStruct<T> host, T... input) {
019 return host.insertFront(input[0]);
020 }
021 });
022 }
023
024 }