⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datastructures.jrag

📁 JDK1.4编译器前端
💻 JRAG
字号:
/* * The JastAdd Extensible Java Compiler (http://jastadd.org) is covered * by the modified BSD License. You should have received a copy of the * modified BSD license with this compiler. *  * Copyright (c) 2005-2008, Torbjorn Ekman * All rights reserved. */aspect DataStructures {  // A persistent Set  interface SimpleSet {    int size();    boolean isEmpty();    SimpleSet add(Object o);    Iterator iterator();    boolean contains(Object o);    SimpleSet emptySet = new SimpleSet() {      public int size() { return 0; }      public boolean isEmpty() { return true; }      public SimpleSet add(Object o) {        if(o instanceof SimpleSet)          return (SimpleSet)o;        return new SimpleSetImpl().add(o);      }      public boolean contains(Object o) { return false; }      public Iterator iterator() { return Collections.EMPTY_LIST.iterator(); }    };    SimpleSet fullSet = new SimpleSet() {      public int size() { throw new Error("Operation size not supported on the full set"); }      public boolean isEmpty() { return false; }      public SimpleSet add(Object o) { return this; }      public boolean contains(Object o) { return true; }      public Iterator iterator() { throw new Error("Operation iterator not support on the full set"); }    };    class SimpleSetImpl implements SimpleSet {      private HashSet internalSet;      public SimpleSetImpl() {        internalSet = new HashSet(4);      }      private SimpleSetImpl(SimpleSetImpl set) {        this.internalSet = new HashSet(set.internalSet);      }      public int size() {        return internalSet.size();      }      public boolean isEmpty() {        return internalSet.isEmpty();      }      public SimpleSet add(Object o) {        if(internalSet.contains(o)) return this;        SimpleSetImpl set = new SimpleSetImpl(this);        set.internalSet.add(o);        return set;      }      public Iterator iterator() {        return internalSet.iterator();      }      public boolean contains(Object o) {        return internalSet.contains(o);      }    }  }  // FieldDeclaration is a SimpleSet  FieldDeclaration implements SimpleSet;  syn int FieldDeclaration.size() = 1;  syn boolean FieldDeclaration.isEmpty() = false;  public SimpleSet FieldDeclaration.add(Object o) {    return new SimpleSetImpl().add(this).add(o);  }  syn boolean FieldDeclaration.contains(Object o) = this == o;    FieldDeclaration implements Iterator;  private FieldDeclaration FieldDeclaration.iterElem;  public Iterator FieldDeclaration.iterator() { iterElem = this; return this; }  public boolean FieldDeclaration.hasNext() { return iterElem != null; }  public Object FieldDeclaration.next() { Object o = iterElem; iterElem = null; return o; }  public void FieldDeclaration.remove() { throw new UnsupportedOperationException(); }  // VariableDeclaration is a SimpleSet  VariableDeclaration implements SimpleSet;  syn int VariableDeclaration.size() = 1;  syn boolean VariableDeclaration.isEmpty() = false;  public SimpleSet VariableDeclaration.add(Object o) {    return new SimpleSetImpl().add(this).add(o);  }  syn boolean VariableDeclaration.contains(Object o) = this == o;    VariableDeclaration implements Iterator;  private VariableDeclaration VariableDeclaration.iterElem;  public Iterator VariableDeclaration.iterator() { iterElem = this; return this; }  public boolean VariableDeclaration.hasNext() { return iterElem != null; }  public Object VariableDeclaration.next() { Object o = iterElem; iterElem = null; return o; }  public void VariableDeclaration.remove() { throw new UnsupportedOperationException(); }    // ParameterDeclaration is a SimpleSet  ParameterDeclaration implements SimpleSet;  syn int ParameterDeclaration.size() = 1;  syn boolean ParameterDeclaration.isEmpty() = false;  public SimpleSet ParameterDeclaration.add(Object o) {    return new SimpleSetImpl().add(this).add(o);  }  syn boolean ParameterDeclaration.contains(Object o) = this == o;    ParameterDeclaration implements Iterator;  private ParameterDeclaration ParameterDeclaration.iterElem;  public Iterator ParameterDeclaration.iterator() { iterElem = this; return this; }  public boolean ParameterDeclaration.hasNext() { return iterElem != null; }  public Object ParameterDeclaration.next() { Object o = iterElem; iterElem = null; return o; }  public void ParameterDeclaration.remove() { throw new UnsupportedOperationException(); }  // TypeDecl is a SimpleSet  TypeDecl implements SimpleSet;  syn int TypeDecl.size() = 1;  syn boolean TypeDecl.isEmpty() = false;  public SimpleSet TypeDecl.add(Object o) {    return new SimpleSetImpl().add(this).add(o);  }  syn boolean TypeDecl.contains(Object o) = this == o;  TypeDecl implements Iterator;  private TypeDecl TypeDecl.iterElem;  public Iterator TypeDecl.iterator() { iterElem = this; return this; }  public boolean TypeDecl.hasNext() { return iterElem != null; }  public Object TypeDecl.next() { Object o = iterElem; iterElem = null; return o; }  public void TypeDecl.remove() { throw new UnsupportedOperationException(); }    // MethodDecl is a SimpleSet  MethodDecl implements SimpleSet;  syn int MethodDecl.size() = 1;  syn boolean MethodDecl.isEmpty() = false;  public SimpleSet MethodDecl.add(Object o) {    return new SimpleSetImpl().add(this).add(o);  }  syn boolean MethodDecl.contains(Object o) = this == o;  MethodDecl implements Iterator;  private MethodDecl MethodDecl.iterElem;  public Iterator MethodDecl.iterator() { iterElem = this; return this; }  public boolean MethodDecl.hasNext() { return iterElem != null; }  public Object MethodDecl.next() { Object o = iterElem; iterElem = null; return o; }  public void MethodDecl.remove() { throw new UnsupportedOperationException(); }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -