dafny.DafnySet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of DafnyRuntime Show documentation
Show all versions of DafnyRuntime Show documentation
Runtime for Dafny programs compiled to Java
The newest version!
// Copyright by the contributors to the Dafny Project
// SPDX-License-Identifier: MIT
package dafny;
import java.util.*;
// A class that is equivalent to the implementation of Set in Dafny
public class DafnySet {
private Set innerSet;
public DafnySet() {
innerSet = new HashSet<>();
}
public DafnySet(Set s) {
assert s != null : "Precondition Violation";
innerSet = new HashSet<>(s);
}
public DafnySet(Collection c) {
assert c != null : "Precondition Violation";
innerSet = new HashSet<>(c);
}
public DafnySet(DafnySet other) {
assert other != null : "Precondition Violation";
innerSet = new HashSet<>(other.innerSet);
}
public DafnySet(List l) {
assert l != null : "Precondition Violation";
innerSet = new HashSet<>(l);
}
@SafeVarargs
public static DafnySet of(T ... elements) {
return new DafnySet(Arrays.asList(elements));
}
private static final DafnySet