Initial commit
This commit is contained in:
17
sll/.editorconfig
Normal file
17
sll/.editorconfig
Normal file
@@ -0,0 +1,17 @@
|
||||
# Editor configuration, see http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 80
|
||||
|
||||
[*.sh]
|
||||
end_of_line = lf
|
||||
|
||||
[*.java]
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
3
sll/.idea/.gitignore
generated
vendored
Normal file
3
sll/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
13
sll/.idea/compiler.xml
generated
Normal file
13
sll/.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="sll" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
7
sll/.idea/encodings.xml
generated
Normal file
7
sll/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
20
sll/.idea/jarRepositories.xml
generated
Normal file
20
sll/.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
12
sll/.idea/misc.xml
generated
Normal file
12
sll/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="18" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
3
sll/.vscode/settings.json
vendored
Normal file
3
sll/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"print.colourScheme": "Atom One"
|
||||
}
|
||||
173
sll/pom.xml
Normal file
173
sll/pom.xml
Normal file
@@ -0,0 +1,173 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tabrizu.ds</groupId>
|
||||
<artifactId>sll</artifactId>
|
||||
<version>1.0</version>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<junit.version>5.6.0</junit.version>
|
||||
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
|
||||
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
|
||||
<checkstyle.version>8.45.1</checkstyle.version>
|
||||
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
||||
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
|
||||
<maven-javadoc-plugin.version>3.0.0</maven-javadoc-plugin.version>
|
||||
<!-- JaCoCo thresholds. Increase gradually as you add tests. -->
|
||||
<jacoco.unit-tests.limit.instruction-ratio>0%</jacoco.unit-tests.limit.instruction-ratio>
|
||||
<jacoco.unit-tests.limit.branch-ratio>0%</jacoco.unit-tests.limit.branch-ratio>
|
||||
<jacoco.unit-tests.limit.class-complexity>20</jacoco.unit-tests.limit.class-complexity>
|
||||
<jacoco.unit-tests.limit.method-complexity>5</jacoco.unit-tests.limit.method-complexity>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>${maven-enforcer-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireMavenVersion>
|
||||
<version>3.6.3</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
<fail>true</fail>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>${maven-checkstyle-plugin.version}</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.puppycrawl.tools</groupId>
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>${checkstyle.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ngeor</groupId>
|
||||
<artifactId>checkstyle-rules</artifactId>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
|
||||
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||
<skip>${skipTests}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>checkstyle</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>${jacoco-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>pre-unit-test</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>post-unit-test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>check-unit-test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
|
||||
<rules>
|
||||
<rule>
|
||||
<element>BUNDLE</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>INSTRUCTION</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>${jacoco.unit-tests.limit.instruction-ratio}</minimum>
|
||||
</limit>
|
||||
<limit>
|
||||
<counter>BRANCH</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>${jacoco.unit-tests.limit.branch-ratio}</minimum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
<rule>
|
||||
<element>CLASS</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>COMPLEXITY</counter>
|
||||
<value>TOTALCOUNT</value>
|
||||
<maximum>${jacoco.unit-tests.limit.class-complexity}</maximum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
<rule>
|
||||
<element>METHOD</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>COMPLEXITY</counter>
|
||||
<value>TOTALCOUNT</value>
|
||||
<maximum>${jacoco.unit-tests.limit.method-complexity}</maximum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${maven-javadoc-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</project>
|
||||
19
sll/src/main/java/com/tabrizu/ds/App.java
Normal file
19
sll/src/main/java/com/tabrizu/ds/App.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.tabrizu.ds;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*/
|
||||
public final class App {
|
||||
private App() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Says hello to the world.
|
||||
* @param args The arguments of the program.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
|
||||
SingleLinkedList<Integer> myList = new SingleLinkedList<Integer>();
|
||||
}
|
||||
}
|
||||
12
sll/src/main/java/com/tabrizu/ds/ISingleLinkedList.java
Normal file
12
sll/src/main/java/com/tabrizu/ds/ISingleLinkedList.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.tabrizu.ds;
|
||||
|
||||
|
||||
public interface ISingleLinkedList<T> {
|
||||
public int size();
|
||||
public void addFirst(T value);
|
||||
public void addLast(T value);
|
||||
public T removeFirst();
|
||||
public T removeLast();
|
||||
public T getFirst();
|
||||
public T getLast();
|
||||
}
|
||||
106
sll/src/main/java/com/tabrizu/ds/SingleLinkedList.java
Normal file
106
sll/src/main/java/com/tabrizu/ds/SingleLinkedList.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package com.tabrizu.ds;
|
||||
|
||||
public class SingleLinkedList<T> implements ISingleLinkedList<T> {
|
||||
|
||||
private class Node {
|
||||
private T m_value;
|
||||
private Node m_next;
|
||||
|
||||
public Node(T value, Node next) {
|
||||
m_value = value;
|
||||
m_next = next;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
public Node getNext() {
|
||||
return m_next;
|
||||
}
|
||||
|
||||
public void setNext(Node next) {
|
||||
m_next = next;
|
||||
}
|
||||
}
|
||||
|
||||
private Node m_head;
|
||||
private Node m_tail;
|
||||
private int m_size;
|
||||
|
||||
public SingleLinkedList() {
|
||||
m_head = null;
|
||||
m_tail = null;
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFirst(T value) {
|
||||
m_head = new Node(value, m_head);
|
||||
if (m_size == 0) {
|
||||
m_tail = m_head;
|
||||
}
|
||||
m_size += 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLast(T value) {
|
||||
if (m_size == 0) {
|
||||
addFirst(value);
|
||||
}
|
||||
Node newNode = new Node(value, null);
|
||||
m_tail.setNext(newNode);
|
||||
m_tail = newNode;
|
||||
m_size++;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public T removeFirst() {
|
||||
if (m_size == 0) {
|
||||
return null;
|
||||
}
|
||||
T lastHead = m_head.getValue();
|
||||
m_head = m_head.getNext();
|
||||
m_size--;
|
||||
|
||||
return lastHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T removeLast() {
|
||||
if (m_size == 0) {
|
||||
return null;
|
||||
}
|
||||
T lastTail = m_tail.getValue();
|
||||
Node currentNode = m_head;
|
||||
while (currentNode.getNext() != null){
|
||||
|
||||
currentNode = currentNode.getNext();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getFirst() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getLast() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
18
sll/src/test/java/com/tabrizu/ds/AppTest.java
Normal file
18
sll/src/test/java/com/tabrizu/ds/AppTest.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.tabrizu.ds;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
class AppTest {
|
||||
/**
|
||||
* Rigorous Test.
|
||||
*/
|
||||
@Test
|
||||
void testApp() {
|
||||
assertEquals(1, 1);
|
||||
}
|
||||
}
|
||||
BIN
sll/target/classes/com/tabrizu/ds/App.class
Normal file
BIN
sll/target/classes/com/tabrizu/ds/App.class
Normal file
Binary file not shown.
BIN
sll/target/classes/com/tabrizu/ds/ISingleLinkedList.class
Normal file
BIN
sll/target/classes/com/tabrizu/ds/ISingleLinkedList.class
Normal file
Binary file not shown.
BIN
sll/target/classes/com/tabrizu/ds/SingleLinkedList$Node.class
Normal file
BIN
sll/target/classes/com/tabrizu/ds/SingleLinkedList$Node.class
Normal file
Binary file not shown.
BIN
sll/target/classes/com/tabrizu/ds/SingleLinkedList.class
Normal file
BIN
sll/target/classes/com/tabrizu/ds/SingleLinkedList.class
Normal file
Binary file not shown.
BIN
sll/target/test-classes/com/tabrizu/ds/AppTest.class
Normal file
BIN
sll/target/test-classes/com/tabrizu/ds/AppTest.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user