JAVA all works
This commit is contained in:
202
semester-4/ОПJа/lb-2/task2/.gitignore
vendored
Normal file
202
semester-4/ОПJа/lb-2/task2/.gitignore
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
|
||||
# Created by https://www.gitignore.io/api/git,java,maven,eclipse,windows
|
||||
|
||||
### Eclipse ###
|
||||
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
|
||||
# CDT- autotools
|
||||
.autotools
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# Tern plugin
|
||||
.tern-project
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
|
||||
# Code Recommenders
|
||||
.recommenders/
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated/
|
||||
|
||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
|
||||
### Eclipse Patch ###
|
||||
# Eclipse Core
|
||||
.project
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated
|
||||
|
||||
.sts4-cache/
|
||||
|
||||
### Git ###
|
||||
# Created by git for backups. To disable backups in Git:
|
||||
# $ git config --global mergetool.keepBackup false
|
||||
*.orig
|
||||
|
||||
# Created by git when using merge tools for conflicts
|
||||
*.BACKUP.*
|
||||
*.BASE.*
|
||||
*.LOCAL.*
|
||||
*.REMOTE.*
|
||||
*_BACKUP_*.txt
|
||||
*_BASE_*.txt
|
||||
*_LOCAL_*.txt
|
||||
*_REMOTE_*.txt
|
||||
|
||||
### Java ###
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Some additional ignores (sort later)
|
||||
*.DS_Store
|
||||
*.sw?
|
||||
.#*
|
||||
*#
|
||||
*~
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
bin
|
||||
build
|
||||
target
|
||||
dependency-reduced-pom.xml
|
||||
*.sublime-*
|
||||
/scratch
|
||||
.gradle
|
||||
README.html
|
||||
*.iml
|
||||
.idea
|
||||
.exercism
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ua.nure.jfn.task2;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class ArrayImpl<T> implements Array<T> {
|
||||
|
||||
@ -11,10 +12,10 @@ public class ArrayImpl<T> implements Array<T> {
|
||||
}
|
||||
|
||||
public ArrayImpl(Container<T> container) {
|
||||
this.elements = new Object[container.size() + 1];
|
||||
elements = new Object[container.size() + 1];
|
||||
|
||||
for (T element : container)
|
||||
this.add(element);
|
||||
add(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,7 +44,7 @@ public class ArrayImpl<T> implements Array<T> {
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -127,7 +128,7 @@ public class ArrayImpl<T> implements Array<T> {
|
||||
@Override
|
||||
public T next() {
|
||||
if (!hasNext())
|
||||
throw new java.util.NoSuchElementException();
|
||||
throw new NoSuchElementException();
|
||||
|
||||
lastReturnedIndex = currentIndex;
|
||||
return (T) elements[currentIndex++];
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ua.nure.jfn.task2;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class ListImpl<T> implements List<T> {
|
||||
|
||||
@ -114,7 +115,7 @@ public class ListImpl<T> implements List<T> {
|
||||
@Override
|
||||
public void removeFirst() {
|
||||
if (head == null)
|
||||
throw new java.util.NoSuchElementException();
|
||||
throw new NoSuchElementException();
|
||||
|
||||
head = head.next;
|
||||
size--;
|
||||
@ -123,7 +124,7 @@ public class ListImpl<T> implements List<T> {
|
||||
@Override
|
||||
public void removeLast() {
|
||||
if (head == null)
|
||||
throw new java.util.NoSuchElementException();
|
||||
throw new NoSuchElementException();
|
||||
|
||||
if (head.isLast())
|
||||
head = null;
|
||||
@ -137,7 +138,7 @@ public class ListImpl<T> implements List<T> {
|
||||
@Override
|
||||
public T getFirst() {
|
||||
if (head == null)
|
||||
throw new java.util.NoSuchElementException();
|
||||
throw new NoSuchElementException();
|
||||
|
||||
return (T) head.data;
|
||||
}
|
||||
@ -146,12 +147,12 @@ public class ListImpl<T> implements List<T> {
|
||||
@Override
|
||||
public T getLast() {
|
||||
if (head == null)
|
||||
throw new java.util.NoSuchElementException();
|
||||
throw new NoSuchElementException();
|
||||
|
||||
if (head.isLast())
|
||||
return (T) head.data;
|
||||
else
|
||||
return (T) head.getLast();
|
||||
|
||||
return (T) head.getLast();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -162,7 +163,8 @@ public class ListImpl<T> implements List<T> {
|
||||
|
||||
if (head.data != null && head.data.equals(element))
|
||||
return (T) head.data;
|
||||
else if (head.next != null)
|
||||
|
||||
if (head.next != null)
|
||||
return (T) head.search(element);
|
||||
|
||||
return null;
|
||||
@ -178,9 +180,8 @@ public class ListImpl<T> implements List<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (head.next != null) {
|
||||
if (head.next != null)
|
||||
return head.remove(element);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -224,7 +225,7 @@ public class ListImpl<T> implements List<T> {
|
||||
@Override
|
||||
public T next() {
|
||||
if (!hasNext())
|
||||
throw new java.util.NoSuchElementException();
|
||||
throw new NoSuchElementException();
|
||||
|
||||
prev = curr;
|
||||
curr = curr.next;
|
||||
|
@ -20,10 +20,9 @@ public class StreamImpl<T> implements Stream<T> {
|
||||
public Container<?> apply(Container<?> input) {
|
||||
Array<T> newContainer = new ArrayImpl<T>();
|
||||
|
||||
for (Object element : input) {
|
||||
for (Object element : input)
|
||||
if (predicate.apply((T) element))
|
||||
newContainer.add((T) element);
|
||||
}
|
||||
|
||||
return newContainer;
|
||||
}
|
||||
@ -41,9 +40,8 @@ public class StreamImpl<T> implements Stream<T> {
|
||||
public Container<?> apply(Container<?> input) {
|
||||
Array<R> newContainer = new ArrayImpl<R>();
|
||||
|
||||
for (Object element : input) {
|
||||
for (Object element : input)
|
||||
newContainer.add(function.apply((T) element));
|
||||
}
|
||||
|
||||
return newContainer;
|
||||
}
|
||||
@ -61,14 +59,14 @@ public class StreamImpl<T> implements Stream<T> {
|
||||
|
||||
@Override
|
||||
public Stream<T> filter(Function<? super T, Boolean> predicate) {
|
||||
Array<Operation> newOperations = new ArrayImpl<>(this.operations);
|
||||
Array<Operation> newOperations = new ArrayImpl<>(operations);
|
||||
newOperations.add(new FilterOperation<>(predicate));
|
||||
return new StreamImpl<T>(source, newOperations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> Stream<R> map(Function<? super T, ? extends R> function) {
|
||||
Array<Operation> newOperations = new ArrayImpl<>(this.operations);
|
||||
Array<Operation> newOperations = new ArrayImpl<>(operations);
|
||||
newOperations.add(new MapOperation<>(function));
|
||||
return new StreamImpl<R>(source, newOperations);
|
||||
}
|
||||
@ -88,13 +86,10 @@ public class StreamImpl<T> implements Stream<T> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void forEach(Action<? super T> action) {
|
||||
for (Operation operation : operations) {
|
||||
for (Operation operation : operations)
|
||||
source = operation.apply(source);
|
||||
}
|
||||
|
||||
for (Object element : source) {
|
||||
for (Object element : source)
|
||||
action.perform((T) element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user