Difference between revisions of "Atomic Stack Assignment"

From CSE231 Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
=Code To Implement=
 
=Code To Implement=
 
==Node==
 
==Node==
 +
<nowiki>public interface Node<E> {
 +
E value();
 +
 +
Optional<Node<E>> nextNode();
 +
}</nowiki>
 +
===DefaultNode===
 +
[https://www.javadoc.io/static/com.google.code.findbugs/jsr305/3.0.1/javax/annotation/concurrent/Immutable.html @Immutable]
 +
 +
==Stack==
 
  <nowiki>public interface Stack<E> {
 
  <nowiki>public interface Stack<E> {
 
void push(E value);
 
void push(E value);
Line 8: Line 17:
 
Optional<E> pop();
 
Optional<E> pop();
 
}</nowiki>
 
}</nowiki>
===DefaultNode===
 
[https://www.javadoc.io/static/com.google.code.findbugs/jsr305/3.0.1/javax/annotation/concurrent/Immutable.html @Immutable]
 
 
==Stack==
 
 
===NotThreadSafeStack===
 
===NotThreadSafeStack===
 
[https://www.javadoc.io/static/com.google.code.findbugs/jsr305/3.0.1/javax/annotation/concurrent/NotThreadSafe.html @NotThreadSafe]
 
[https://www.javadoc.io/static/com.google.code.findbugs/jsr305/3.0.1/javax/annotation/concurrent/NotThreadSafe.html @NotThreadSafe]

Revision as of 03:05, 6 November 2022

Code To Implement

Node

public interface Node<E> {
	E value();

	Optional<Node<E>> nextNode();
}

DefaultNode

@Immutable

Stack

public interface Stack<E> {
	void push(E value);

	Optional<E> peek();

	Optional<E> pop();
}

NotThreadSafeStack

@NotThreadSafe

ConcurrentStack

@ThreadSafe

AtomicStack

@ThreadSafe

Testing

class: StackTestSuite.java Junit.png
package: stack.exercise
source folder: testing/src/test/java

DefaultNode

class: _DefaultNodeTestSuite.java Junit.png
package: stack.node.exercise
source folder: testing/src/test/java

NotThreadSafeStack

class: _NotThreadSafeStackTestSuite.java Junit.png
package: stack.notthreadsafe.exercise
source folder: testing/src/test/java

ConcurrentStack

class: __ConcurrentStackTestSuite.java Junit.png
package: stack.concurrent.exercise
source folder: testing/src/test/java

sequential

class: _ConcurrentStackSequentialTestSuite.java Junit.png
package: stack.concurrent.exercise
source folder: testing/src/test/java

parallel

class: _ConcurrentStackParallelTestSuite.java Junit.png
package: stack.concurrent.exercise
source folder: testing/src/test/java

AtomicStack

class: __AtomicStackTestSuite.java Junit.png
package: stack.atomic.exercise
source folder: testing/src/test/java

sequential

class: _AtomicStackSequentialTestSuite.java Junit.png
package: stack.atomic.exercise
source folder: testing/src/test/java

parallel

class: _AtomicStackParallelTestSuite.java Junit.png
package: stack.atomic.exercise
source folder: testing/src/test/java