diff --git a/.metadata/.lock_info b/.metadata/.lock_info index 694992f..0482fcb 100644 --- a/.metadata/.lock_info +++ b/.metadata/.lock_info @@ -1,4 +1,4 @@ -#Sun May 10 18:29:39 CEST 2026 +#Tue May 12 13:59:16 CEST 2026 host=DESKTOP-ALBQHEK -process-id=13748 +process-id=5624 user=eslusarz diff --git a/.metadata/.log b/.metadata/.log index d965545..0c4da35 100644 --- a/.metadata/.log +++ b/.metadata/.log @@ -712,3 +712,182 @@ user global configuration and to define the default location to store repositori not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and EGit might behave differently since they see different configuration options. This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. +!SESSION 2026-05-11 17:50:40.634 ----------------------------------------------- +eclipse.buildId=4.39.0.20260305-0817 +java.version=21.0.10 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY ch.qos.logback.classic 1 0 2026-05-11 17:51:16.095 +!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized. + +!ENTRY ch.qos.logback.classic 1 0 2026-05-11 17:51:21.877 +!MESSAGE Logback config file: C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.m2e.logback\logback.2.7.101.20251017-1242.xml + +!ENTRY org.eclipse.e4.ui.workbench 4 0 2026-05-11 17:51:24.468 +!MESSAGE Unable to load class 'org.eclipse.e4.ui.workbench.renderers.swt.cocoa.CocoaUIHandler' from bundle '147' +!STACK 0 +java.lang.ClassNotFoundException: org.eclipse.e4.ui.workbench.renderers.swt.cocoa.CocoaUIHandler cannot be found by org.eclipse.e4.ui.workbench.renderers.swt_0.17.0.v20260131-0926 + at org.eclipse.osgi.internal.loader.BundleLoader.generateException(BundleLoader.java:570) + at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:564) + at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:439) + at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:195) + at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) + at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:663) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:88) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:59) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:37) + at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:276) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:603) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:583) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:185) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:219) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:149) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:115) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:467) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:298) + at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) + at java.base/java.lang.reflect.Method.invoke(Method.java:580) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:615) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:563) + at org.eclipse.equinox.launcher.Main.run(Main.java:1415) + +!ENTRY org.eclipse.egit.ui 2 0 2026-05-11 17:51:48.540 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\eslusarz'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.eclipse.jdt.ui 4 2 2026-05-11 22:27:29.855 +!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui". +!STACK 0 +java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.core.dom.CompilationUnit.getModule()" because "astRoot" is null + at org.eclipse.jdt.internal.ui.text.correction.proposals.AddModuleRequiresCorrectionProposalCore.createAddRequiresChange(AddModuleRequiresCorrectionProposalCore.java:87) + at org.eclipse.jdt.internal.ui.text.correction.proposals.AddModuleRequiresCorrectionProposalCore.createChange(AddModuleRequiresCorrectionProposalCore.java:73) + at org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore.getChange(ChangeCorrectionProposalCore.java:153) + at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsBaseSubProcessor.getCompositeChangeProposal(UnresolvedElementsBaseSubProcessor.java:1080) + at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsBaseSubProcessor.getCompositeChangeProposal(UnresolvedElementsBaseSubProcessor.java:1072) + at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsBaseSubProcessor.addSimilarTypeProposals(UnresolvedElementsBaseSubProcessor.java:1037) + at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsBaseSubProcessor.collectTypeProposals(UnresolvedElementsBaseSubProcessor.java:791) + at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.getTypeProposals(UnresolvedElementsSubProcessor.java:143) + at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:450) + at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections(QuickFixProcessor.java:370) + at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(JavaCorrectionProcessor.java:381) + at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.run(JavaCorrectionProcessor.java:341) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47) + at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.process(JavaCorrectionProcessor.java:336) + at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:465) + at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getJavaAnnotationFixes(ProblemHover.java:115) + at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.computeCompletionProposals(ProblemHover.java:89) + at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.(ProblemHover.java:74) + at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover.createAnnotationInfo(ProblemHover.java:178) + at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover.getHoverInfo2(AbstractAnnotationHover.java:957) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:165) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:131) + at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:89) + at org.eclipse.jface.text.TextViewerHoverManager$1.run(TextViewerHoverManager.java:155) + +!ENTRY org.eclipse.jdt.ui 4 10001 2026-05-11 22:30:29.246 +!MESSAGE Internal Error +!STACK 1 +Java Model Exception: Error in Java Model (code 969): MyLinkedListIterator [in [Working copy] MyLinkedList.java [in list.mylinkedlist [in src [in asdl]]]] does not exist + at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:548) + at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:591) + at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:294) + at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:280) + at org.eclipse.jdt.internal.core.SourceRefElement.getSourceRange(SourceRefElement.java:258) + at org.eclipse.jdt.internal.core.Member.getJavadocRange(Member.java:322) + at org.eclipse.jdt.core.manipulation.internal.javadoc.CoreJavadocAccess.getHTMLContentFromSource(CoreJavadocAccess.java:359) + at org.eclipse.jdt.core.manipulation.internal.javadoc.CoreJavadocAccess.getHTMLContent(CoreJavadocAccess.java:229) + at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:49) + at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.createJavadocProposal(AbstractAnnotationHover.java:365) + at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.deferredCreateContent(AbstractAnnotationHover.java:336) + at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.setInput(AbstractAnnotationHover.java:204) + at org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(AbstractInformationControlManager.java:1178) + at org.eclipse.jface.text.AbstractInformationControlManager.presentInformation(AbstractInformationControlManager.java:1147) + at org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation(AbstractHoverInformationControlManager.java:903) + at org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation(TextViewerHoverManager.java:242) + at org.eclipse.jface.text.TextViewerHoverManager.lambda$3(TextViewerHoverManager.java:232) + at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40) + at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132) + at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4122) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3738) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1051) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:684) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:583) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:185) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:219) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:149) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:115) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:467) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:298) + at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) + at java.base/java.lang.reflect.Method.invoke(Method.java:580) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:615) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:563) + at org.eclipse.equinox.launcher.Main.run(Main.java:1415) +!SUBENTRY 1 org.eclipse.jdt.core 4 969 2026-05-11 22:30:29.248 +!MESSAGE MyLinkedListIterator [in [Working copy] MyLinkedList.java [in list.mylinkedlist [in src [in asdl]]]] does not exist +!SESSION 2026-05-12 13:58:49.453 ----------------------------------------------- +eclipse.buildId=4.39.0.20260305-0817 +java.version=21.0.10 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY ch.qos.logback.classic 1 0 2026-05-12 13:59:13.439 +!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized. + +!ENTRY org.eclipse.core.resources 2 10035 2026-05-12 13:59:16.479 +!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes. + +!ENTRY ch.qos.logback.classic 1 0 2026-05-12 13:59:17.756 +!MESSAGE Logback config file: C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.m2e.logback\logback.2.7.101.20251017-1242.xml + +!ENTRY org.eclipse.e4.ui.workbench 4 0 2026-05-12 13:59:19.267 +!MESSAGE Unable to load class 'org.eclipse.e4.ui.workbench.renderers.swt.cocoa.CocoaUIHandler' from bundle '147' +!STACK 0 +java.lang.ClassNotFoundException: org.eclipse.e4.ui.workbench.renderers.swt.cocoa.CocoaUIHandler cannot be found by org.eclipse.e4.ui.workbench.renderers.swt_0.17.0.v20260131-0926 + at org.eclipse.osgi.internal.loader.BundleLoader.generateException(BundleLoader.java:570) + at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:564) + at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:439) + at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:195) + at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) + at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:663) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:88) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:59) + at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:37) + at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:276) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:603) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:583) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:185) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:219) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:149) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:115) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:467) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:298) + at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) + at java.base/java.lang.reflect.Method.invoke(Method.java:580) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:615) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:563) + at org.eclipse.equinox.launcher.Main.run(Main.java:1415) + +!ENTRY org.eclipse.egit.ui 2 0 2026-05-12 13:59:35.401 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\eslusarz'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. diff --git a/.metadata/.plugins/org.eclipse.buildship.core/gradle/versions.json b/.metadata/.plugins/org.eclipse.buildship.core/gradle/versions.json index 4be6b3d..786b7e2 100644 --- a/.metadata/.plugins/org.eclipse.buildship.core/gradle/versions.json +++ b/.metadata/.plugins/org.eclipse.buildship.core/gradle/versions.json @@ -1,7 +1,7 @@ [ { - "version" : "9.6.0-20260502004807+0000", - "buildTime" : "20260502004807+0000", - "commitId" : "b6e68b2bcae07ceceb366b4d0a900e4e93ba4c1d", + "version" : "9.6.0-20260511004857+0000", + "buildTime" : "20260511004857+0000", + "commitId" : "d21d434e616b55c833aa59b433adf393010f40d8", "current" : false, "snapshot" : true, "nightly" : true, @@ -10,11 +10,62 @@ "rcFor" : "", "milestoneFor" : "", "broken" : false, - "downloadUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.6.0-20260502004807+0000-bin.zip", - "checksumUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.6.0-20260502004807+0000-bin.zip.sha256", - "checksum" : "85e34aa0a33686cfac1fb2e0ca79c6e4929be140ec8dae7956fb6b84241270b5", - "wrapperChecksumUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.6.0-20260502004807+0000-wrapper.jar.sha256", + "downloadUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.6.0-20260511004857+0000-bin.zip", + "checksumUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.6.0-20260511004857+0000-bin.zip.sha256", + "checksum" : "6c9696b888885a574308bdead2ef69761b6fac15b21ad5f0d58d26088fda1a9c", + "wrapperChecksumUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.6.0-20260511004857+0000-wrapper.jar.sha256", "wrapperChecksum" : "497c8c2a7e5031f6aa847f88104aa80a93532ec32ee17bdb8d1d2f67a194a9c7" +}, { + "version" : "9.6.0-milestone-2", + "buildTime" : "20260510110612+0000", + "commitId" : "62000451ad7b25de53fa89a155ef8ecb401621bb", + "current" : false, + "snapshot" : false, + "nightly" : false, + "releaseNightly" : false, + "activeRc" : false, + "rcFor" : "", + "milestoneFor" : "9.6.0", + "broken" : false, + "downloadUrl" : "https://services.gradle.org/distributions/gradle-9.6.0-milestone-2-bin.zip", + "checksumUrl" : "https://services.gradle.org/distributions/gradle-9.6.0-milestone-2-bin.zip.sha256", + "checksum" : "a67385a5e8acaed7840b5114feb76e455f6e3567e02d4414726f6fd1179753a9", + "wrapperChecksumUrl" : "https://services.gradle.org/distributions/gradle-9.6.0-milestone-2-wrapper.jar.sha256", + "wrapperChecksum" : "497c8c2a7e5031f6aa847f88104aa80a93532ec32ee17bdb8d1d2f67a194a9c7" +}, { + "version" : "9.5.1-20260510022507+0000", + "buildTime" : "20260510022507+0000", + "commitId" : "fd78213f09782e62ca4957f9cfd3d90c6c3f1767", + "current" : false, + "snapshot" : true, + "nightly" : false, + "releaseNightly" : true, + "activeRc" : false, + "rcFor" : "", + "milestoneFor" : "", + "broken" : false, + "downloadUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.5.1-20260510022507+0000-bin.zip", + "checksumUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.5.1-20260510022507+0000-bin.zip.sha256", + "checksum" : "31ee63072850e69db0372d24655dbef7680aee3afaec2442d6395fc7ca672fd2", + "wrapperChecksumUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.5.1-20260510022507+0000-wrapper.jar.sha256", + "wrapperChecksum" : "497c8c2a7e5031f6aa847f88104aa80a93532ec32ee17bdb8d1d2f67a194a9c7" +}, { + "version" : "8.14.5", + "buildTime" : "20260507110329+0000", + "commitId" : "62345becae08b13e793521816d585102fea66398", + "current" : false, + "snapshot" : false, + "nightly" : false, + "releaseNightly" : false, + "activeRc" : false, + "rcFor" : "", + "milestoneFor" : "", + "broken" : false, + "downloadUrl" : "https://services.gradle.org/distributions/gradle-8.14.5-bin.zip", + "checksumUrl" : "https://services.gradle.org/distributions/gradle-8.14.5-bin.zip.sha256", + "checksum" : "6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854", + "wrapperChecksumUrl" : "https://services.gradle.org/distributions/gradle-8.14.5-wrapper.jar.sha256", + "wrapperChecksum" : "7d3a4ac4de1c32b59bc6a4eb8ecb8e612ccd0cf1ae1e99f66902da64df296172" }, { "version" : "9.5.0", "buildTime" : "20260428120530+0000", @@ -32,23 +83,6 @@ "checksum" : "553c78f50dafcd54d65b9a444649057857469edf836431389695608536d6b746", "wrapperChecksumUrl" : "https://services.gradle.org/distributions/gradle-9.5.0-wrapper.jar.sha256", "wrapperChecksum" : "497c8c2a7e5031f6aa847f88104aa80a93532ec32ee17bdb8d1d2f67a194a9c7" -}, { - "version" : "9.5.0-20260428014943+0000", - "buildTime" : "20260428014943+0000", - "commitId" : "3fe117d68f3907790f3809f121aa36303a9151f8", - "current" : false, - "snapshot" : true, - "nightly" : false, - "releaseNightly" : true, - "activeRc" : false, - "rcFor" : "", - "milestoneFor" : "", - "broken" : false, - "downloadUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.5.0-20260428014943+0000-bin.zip", - "checksumUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.5.0-20260428014943+0000-bin.zip.sha256", - "checksum" : "95be4dddffc251cf96cb85e6b7d5b1cf9ac7aa407c12c0b1ef212d8592c98ad0", - "wrapperChecksumUrl" : "https://services.gradle.org/distributions-snapshots/gradle-9.5.0-20260428014943+0000-wrapper.jar.sha256", - "wrapperChecksum" : "497c8c2a7e5031f6aa847f88104aa80a93532ec32ee17bdb8d1d2f67a194a9c7" }, { "version" : "9.5.0-rc-4", "buildTime" : "20260423134125+0000", diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/0/506478077c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/0/506478077c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..305cd82 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/0/506478077c4d001117ad98d4e911bb97 @@ -0,0 +1,296 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + Node currentNode = head; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/0/f08464e1364d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/0/f08464e1364d0011135ca7e1c9885acd deleted file mode 100644 index 5f51121..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/0/f08464e1364d0011135ca7e1c9885acd +++ /dev/null @@ -1,98 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1/20722979fd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/1/20722979fd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..08edfdc --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1/20722979fd4d00111282df97d7c4d0e2 @@ -0,0 +1,414 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(); + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/11/40104dac754d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/11/40104dac754d001117ad98d4e911bb97 new file mode 100644 index 0000000..e9d80c9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/11/40104dac754d001117ad98d4e911bb97 @@ -0,0 +1,225 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/11/a0a17875a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/11/a0a17875a94c0011135ca7e1c9885acd deleted file mode 100644 index 4cf2dc5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/11/a0a17875a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,9 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - */ -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/12/4056f154794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/12/4056f154794d001117ad98d4e911bb97 new file mode 100644 index 0000000..7601bcb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/12/4056f154794d001117ad98d4e911bb97 @@ -0,0 +1,273 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/13/1008b20d5b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/13/1008b20d5b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..b9e99b3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/13/1008b20d5b4d001117ad98d4e911bb97 @@ -0,0 +1,195 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if () + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/13/2024ff882f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/13/2024ff882f4d0011135ca7e1c9885acd deleted file mode 100644 index ffdd3d5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/13/2024ff882f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,51 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/13/40a97f1b364d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/13/40a97f1b364d0011135ca7e1c9885acd deleted file mode 100644 index ca68c64..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/13/40a97f1b364d0011135ca7e1c9885acd +++ /dev/null @@ -1,96 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - - } else { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/13/c0b854a3354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/13/c0b854a3354d0011135ca7e1c9885acd deleted file mode 100644 index bb22b37..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/13/c0b854a3354d0011135ca7e1c9885acd +++ /dev/null @@ -1,85 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/14/20c737b9324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/14/20c737b9324d0011135ca7e1c9885acd deleted file mode 100644 index 0d66c16..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/14/20c737b9324d0011135ca7e1c9885acd +++ /dev/null @@ -1,73 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - if (size == 1) { - E tmp = head.data; - head = tail = null; - return tmp; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/14/50a33ded784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/14/50a33ded784d001117ad98d4e911bb97 new file mode 100644 index 0000000..a7ff156 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/14/50a33ded784d001117ad98d4e911bb97 @@ -0,0 +1,273 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext = 0; + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/14/d04502475b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/14/d04502475b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..a3b6656 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/14/d04502475b4d001117ad98d4e911bb97 @@ -0,0 +1,202 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(object); + } + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/15/0009df8d764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/15/0009df8d764d001117ad98d4e911bb97 new file mode 100644 index 0000000..e74a440 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/15/0009df8d764d001117ad98d4e911bb97 @@ -0,0 +1,237 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/15/e0b9f10afb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/15/e0b9f10afb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..2f97781 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/15/e0b9f10afb4d00111282df97d7c4d0e2 @@ -0,0 +1,393 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/16/40767bf61e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/16/40767bf61e4d0011135ca7e1c9885acd deleted file mode 100644 index 648d536..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/16/40767bf61e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,28 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/16/9011665d874d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/16/9011665d874d001117ad98d4e911bb97 new file mode 100644 index 0000000..8bd005b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/16/9011665d874d001117ad98d4e911bb97 @@ -0,0 +1,386 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + size--; + nextNode = nNode; + prevNode = pNode; + posNext--; + lastReturned = null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/19/20b9c8ddfd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/19/20b9c8ddfd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..46f9cea --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/19/20b9c8ddfd4d00111282df97d7c4d0e2 @@ -0,0 +1,424 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/19/40b22efa764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/19/40b22efa764d001117ad98d4e911bb97 new file mode 100644 index 0000000..f03eb7d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/19/40b22efa764d001117ad98d4e911bb97 @@ -0,0 +1,248 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + + return array; + } + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1b/3063929c394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/1b/3063929c394d0011135ca7e1c9885acd deleted file mode 100644 index dccb934..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1b/3063929c394d0011135ca7e1c9885acd +++ /dev/null @@ -1,134 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1b/80da122b594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/1b/80da122b594d001117ad98d4e911bb97 new file mode 100644 index 0000000..a7c4c15 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1b/80da122b594d001117ad98d4e911bb97 @@ -0,0 +1,203 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + } + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/90aa9917384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/90aa9917384d0011135ca7e1c9885acd deleted file mode 100644 index 5829839..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/90aa9917384d0011135ca7e1c9885acd +++ /dev/null @@ -1,115 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/e0b0cc478e4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/e0b0cc478e4c0011135ca7e1c9885acd deleted file mode 100644 index e69de29..0000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/00b82720fb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/00b82720fb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..1a4f737 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/00b82720fb4d00111282df97d7c4d0e2 @@ -0,0 +1,399 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/90e90f4b814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/90e90f4b814d001117ad98d4e911bb97 new file mode 100644 index 0000000..7d6afac --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/90e90f4b814d001117ad98d4e911bb97 @@ -0,0 +1,367 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1e/406f9e107f4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/1e/406f9e107f4d001117ad98d4e911bb97 new file mode 100644 index 0000000..35e7ab5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1e/406f9e107f4d001117ad98d4e911bb97 @@ -0,0 +1,340 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1e/5076a02b1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/1e/5076a02b1e4d0011135ca7e1c9885acd deleted file mode 100644 index d9a928f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1e/5076a02b1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,12 +0,0 @@ -package list.mylinkedlist; - -import java.array.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1f/d009d1e07e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/1f/d009d1e07e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..062ef6e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1f/d009d1e07e4d001117ad98d4e911bb97 @@ -0,0 +1,334 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2/a0f255c8594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2/a0f255c8594d001117ad98d4e911bb97 new file mode 100644 index 0000000..9d6c65f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2/a0f255c8594d001117ad98d4e911bb97 @@ -0,0 +1,212 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/20/e0591369594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/20/e0591369594d001117ad98d4e911bb97 new file mode 100644 index 0000000..ac86a36 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/20/e0591369594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/21/9096dee0fb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/21/9096dee0fb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..1b879f5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/21/9096dee0fb4d00111282df97d7c4d0e2 @@ -0,0 +1,408 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(); + // Se la lista è vuota + if (size == 0) { + tail = head = new Node(data, null, null); + size++; + prevNode = + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/22/302633ba764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/22/302633ba764d001117ad98d4e911bb97 new file mode 100644 index 0000000..bc74ea1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/22/302633ba764d001117ad98d4e911bb97 @@ -0,0 +1,239 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[]; + Node currentNode = head; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/22/804feb72374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/22/804feb72374d0011135ca7e1c9885acd deleted file mode 100644 index bfde662..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/22/804feb72374d0011135ca7e1c9885acd +++ /dev/null @@ -1,113 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - - } else { - - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/23/50874d9b5e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/23/50874d9b5e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..2a31686 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/23/50874d9b5e4d001117ad98d4e911bb97 @@ -0,0 +1,238 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + return true; + } else return removeRec(head.next, object); + } + + private boolean removeRec(Node current, E object) { + if (current == null) return false; + if (current.data.equals(object)) { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/24/a07c963e784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/24/a07c963e784d001117ad98d4e911bb97 new file mode 100644 index 0000000..af7abb7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/24/a07c963e784d001117ad98d4e911bb97 @@ -0,0 +1,263 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/25/7093adeb364d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/25/7093adeb364d0011135ca7e1c9885acd deleted file mode 100644 index 77fc35f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/25/7093adeb364d0011135ca7e1c9885acd +++ /dev/null @@ -1,99 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/25/8073d745314d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/25/8073d745314d0011135ca7e1c9885acd deleted file mode 100644 index 730b57d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/25/8073d745314d0011135ca7e1c9885acd +++ /dev/null @@ -1,59 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(); - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/26/0069b83a814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/26/0069b83a814d001117ad98d4e911bb97 new file mode 100644 index 0000000..2d2c4fd --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/26/0069b83a814d001117ad98d4e911bb97 @@ -0,0 +1,368 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + Node removingNode = head; + Node nextingNode = removingNode.next; + + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/26/40665d03aa4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/26/40665d03aa4c0011135ca7e1c9885acd deleted file mode 100644 index d97c883..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/26/40665d03aa4c0011135ca7e1c9885acd +++ /dev/null @@ -1,22 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - - protected static - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/26/b09ad2cf594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/26/b09ad2cf594d001117ad98d4e911bb97 new file mode 100644 index 0000000..a135ffc --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/26/b09ad2cf594d001117ad98d4e911bb97 @@ -0,0 +1,212 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/27/60ac05aa354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/27/60ac05aa354d0011135ca7e1c9885acd deleted file mode 100644 index a3adcbe..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/27/60ac05aa354d0011135ca7e1c9885acd +++ /dev/null @@ -1,88 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/27/90bc5f635a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/27/90bc5f635a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..c61e800 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/27/90bc5f635a4d001117ad98d4e911bb97 @@ -0,0 +1,219 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + currentNode = currentNode.next; + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + size--; + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/27/a0fa92045b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/27/a0fa92045b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..79d4c9a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/27/a0fa92045b4d001117ad98d4e911bb97 @@ -0,0 +1,195 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/27/d0b5b782314d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/27/d0b5b782314d0011135ca7e1c9885acd deleted file mode 100644 index c9da833..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/27/d0b5b782314d0011135ca7e1c9885acd +++ /dev/null @@ -1,60 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/29/306179641e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/29/306179641e4d0011135ca7e1c9885acd deleted file mode 100644 index 8551566..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/29/306179641e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,20 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/29/40140044594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/29/40140044594d001117ad98d4e911bb97 new file mode 100644 index 0000000..095875b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/29/40140044594d001117ad98d4e911bb97 @@ -0,0 +1,207 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if () + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2a/4078db2e7a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2a/4078db2e7a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..e3d497f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2a/4078db2e7a4d001117ad98d4e911bb97 @@ -0,0 +1,287 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + lastReturned = null; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2a/9081abb57e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2a/9081abb57e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..605c225 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2a/9081abb57e4d001117ad98d4e911bb97 @@ -0,0 +1,329 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2b/009d006b2f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/2b/009d006b2f4d0011135ca7e1c9885acd deleted file mode 100644 index 0ec4c01..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2b/009d006b2f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,48 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2b/a0823937594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2b/a0823937594d001117ad98d4e911bb97 new file mode 100644 index 0000000..33195f7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2b/a0823937594d001117ad98d4e911bb97 @@ -0,0 +1,206 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2b/f0bf9dca7e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2b/f0bf9dca7e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..6f10ec2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2b/f0bf9dca7e4d001117ad98d4e911bb97 @@ -0,0 +1,330 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2c/908c974b334d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/2c/908c974b334d0011135ca7e1c9885acd deleted file mode 100644 index 56a77e7..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2c/908c974b334d0011135ca7e1c9885acd +++ /dev/null @@ -1,76 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - head.next.prev = null; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/401ce2e9784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/401ce2e9784d001117ad98d4e911bb97 new file mode 100644 index 0000000..af27345 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/401ce2e9784d001117ad98d4e911bb97 @@ -0,0 +1,271 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/502ec652784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/502ec652784d001117ad98d4e911bb97 new file mode 100644 index 0000000..46e0c9a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/502ec652784d001117ad98d4e911bb97 @@ -0,0 +1,268 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Metodi adoperati + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/a00f7051354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/a00f7051354d0011135ca7e1c9885acd deleted file mode 100644 index 2f01896..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/a00f7051354d0011135ca7e1c9885acd +++ /dev/null @@ -1,83 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/b0b57503594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/b0b57503594d001117ad98d4e911bb97 new file mode 100644 index 0000000..818c84c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/b0b57503594d001117ad98d4e911bb97 @@ -0,0 +1,201 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/604ff500384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/2e/604ff500384d0011135ca7e1c9885acd deleted file mode 100644 index fd6552f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/604ff500384d0011135ca7e1c9885acd +++ /dev/null @@ -1,114 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/20c41a307c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/20c41a307c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..ff4537a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/20c41a307c4d001117ad98d4e911bb97 @@ -0,0 +1,300 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + Node currentNode = head; + int i = 0; + while () { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/40e6fba1874d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/40e6fba1874d001117ad98d4e911bb97 new file mode 100644 index 0000000..449e45f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/40e6fba1874d001117ad98d4e911bb97 @@ -0,0 +1,391 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + @Override + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/e0fb2b165b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/e0fb2b165b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..2cb1870 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/e0fb2b165b4d001117ad98d4e911bb97 @@ -0,0 +1,197 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/f0f735ee764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/f0f735ee764d001117ad98d4e911bb97 new file mode 100644 index 0000000..666a84c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/f0f735ee764d001117ad98d4e911bb97 @@ -0,0 +1,244 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i] = currentNode; + i++; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3/706178ea7b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/3/706178ea7b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..f22296f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3/706178ea7b4d001117ad98d4e911bb97 @@ -0,0 +1,294 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3/a0dd3419304d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3/a0dd3419304d0011135ca7e1c9885acd deleted file mode 100644 index eb1f9b3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3/a0dd3419304d0011135ca7e1c9885acd +++ /dev/null @@ -1,59 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node - } else { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3/d00b22df324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3/d00b22df324d0011135ca7e1c9885acd deleted file mode 100644 index 9802d36..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3/d00b22df324d0011135ca7e1c9885acd +++ /dev/null @@ -1,77 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - tmp = head.data; - head = tail = null; - } else { - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/30/f081edd52f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/30/f081edd52f4d0011135ca7e1c9885acd deleted file mode 100644 index 630179b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/30/f081edd52f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,54 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/3019efdd764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/31/3019efdd764d001117ad98d4e911bb97 new file mode 100644 index 0000000..8acfa09 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/31/3019efdd764d001117ad98d4e911bb97 @@ -0,0 +1,243 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + for () { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/5021a0f7384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/31/5021a0f7384d0011135ca7e1c9885acd deleted file mode 100644 index 70987af..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/31/5021a0f7384d0011135ca7e1c9885acd +++ /dev/null @@ -1,126 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/a079cbd0594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/31/a079cbd0594d001117ad98d4e911bb97 new file mode 100644 index 0000000..e0fcc2a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/31/a079cbd0594d001117ad98d4e911bb97 @@ -0,0 +1,213 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/e0852927aa4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/31/e0852927aa4c0011135ca7e1c9885acd deleted file mode 100644 index 1150f55..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/31/e0852927aa4c0011135ca7e1c9885acd +++ /dev/null @@ -1,24 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - - protected static Map ContaDuplicati(BinaryNode node, HashMap ) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/e09a142e2f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/31/e09a142e2f4d0011135ca7e1c9885acd deleted file mode 100644 index a835c46..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/31/e09a142e2f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,37 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MuLinkedList() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/f0b898c0764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/31/f0b898c0764d001117ad98d4e911bb97 new file mode 100644 index 0000000..2fdd02e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/31/f0b898c0764d001117ad98d4e911bb97 @@ -0,0 +1,239 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/32/b0a924c5764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/32/b0a924c5764d001117ad98d4e911bb97 new file mode 100644 index 0000000..e1c94f8 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/32/b0a924c5764d001117ad98d4e911bb97 @@ -0,0 +1,240 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/33/9006da815e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/33/9006da815e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..54bbacf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/33/9006da815e4d001117ad98d4e911bb97 @@ -0,0 +1,235 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + return true; + } else return removeRec(head.next, object); + } + + private boolean removeRec(Node cur, E object) { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/33/b0ecb5b67e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/33/b0ecb5b67e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..b747358 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/33/b0ecb5b67e4d001117ad98d4e911bb97 @@ -0,0 +1,329 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/33/d0662990794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/33/d0662990794d001117ad98d4e911bb97 new file mode 100644 index 0000000..053fa58 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/33/d0662990794d001117ad98d4e911bb97 @@ -0,0 +1,281 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0)) + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/34/208a9ecdfd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/34/208a9ecdfd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..1b1b3fe --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/34/208a9ecdfd4d00111282df97d7c4d0e2 @@ -0,0 +1,423 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/34/40483466794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/34/40483466794d001117ad98d4e911bb97 new file mode 100644 index 0000000..bb6dd02 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/34/40483466794d001117ad98d4e911bb97 @@ -0,0 +1,276 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/34/702de21dfe4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/34/702de21dfe4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..851934f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/34/702de21dfe4d00111282df97d7c4d0e2 @@ -0,0 +1,428 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = nextNode; + newNode.next = prevNode; + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/34/f09218291e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/34/f09218291e4d0011135ca7e1c9885acd deleted file mode 100644 index 3656c5b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/34/f09218291e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,12 +0,0 @@ -package list.mylinkedlist; - -implements java.array.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/35/600e04139f4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/35/600e04139f4c0011135ca7e1c9885acd deleted file mode 100644 index abe4ec4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/35/600e04139f4c0011135ca7e1c9885acd +++ /dev/null @@ -1,5 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/35/90392959374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/35/90392959374d0011135ca7e1c9885acd deleted file mode 100644 index 56f0f0a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/35/90392959374d0011135ca7e1c9885acd +++ /dev/null @@ -1,107 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/35/a0048f3b5a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/35/a0048f3b5a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..c2c5dee --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/35/a0048f3b5a4d001117ad98d4e911bb97 @@ -0,0 +1,218 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + currentNode = currentNode.next; + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/36/705091945b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/36/705091945b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..8813f46 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/36/705091945b4d001117ad98d4e911bb97 @@ -0,0 +1,211 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/36/908d1035a84c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/36/908d1035a84c0011135ca7e1c9885acd deleted file mode 100644 index be5bea9..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/36/908d1035a84c0011135ca7e1c9885acd +++ /dev/null @@ -1,5 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/36/c082b4c4764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/36/c082b4c4764d001117ad98d4e911bb97 new file mode 100644 index 0000000..2fdd02e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/36/c082b4c4764d001117ad98d4e911bb97 @@ -0,0 +1,239 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/37/30fe89b7814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/37/30fe89b7814d001117ad98d4e911bb97 new file mode 100644 index 0000000..6ccd5f5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/37/30fe89b7814d001117ad98d4e911bb97 @@ -0,0 +1,372 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/37/b0a1ebe6fe4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/37/b0a1ebe6fe4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..670d19b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/37/b0a1ebe6fe4d00111282df97d7c4d0e2 @@ -0,0 +1,432 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/38/2003b3e4774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/38/2003b3e4774d001117ad98d4e911bb97 new file mode 100644 index 0000000..cc6ce14 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/38/2003b3e4774d001117ad98d4e911bb97 @@ -0,0 +1,256 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/38/30df62ef764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/38/30df62ef764d001117ad98d4e911bb97 new file mode 100644 index 0000000..c11cfc3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/38/30df62ef764d001117ad98d4e911bb97 @@ -0,0 +1,243 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/38/505233b7374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/38/505233b7374d0011135ca7e1c9885acd deleted file mode 100644 index b82113c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/38/505233b7374d0011135ca7e1c9885acd +++ /dev/null @@ -1,114 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(); - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/38/6015615c1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/38/6015615c1e4d0011135ca7e1c9885acd deleted file mode 100644 index 8551566..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/38/6015615c1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,20 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/39/0068e6885b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/39/0068e6885b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..109cf22 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/39/0068e6885b4d001117ad98d4e911bb97 @@ -0,0 +1,211 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/39/80bbd1b35d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/39/80bbd1b35d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..ada9438 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/39/80bbd1b35d4d001117ad98d4e911bb97 @@ -0,0 +1,227 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/39/90f4027a814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/39/90f4027a814d001117ad98d4e911bb97 new file mode 100644 index 0000000..0d68f63 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/39/90f4027a814d001117ad98d4e911bb97 @@ -0,0 +1,369 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0 + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/39/d01a358c7c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/39/d01a358c7c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..09f9cb3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/39/d01a358c7c4d001117ad98d4e911bb97 @@ -0,0 +1,301 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/00c71b815b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/00c71b815b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..52a7593 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/00c71b815b4d001117ad98d4e911bb97 @@ -0,0 +1,209 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/403df5a8764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/403df5a8764d001117ad98d4e911bb97 new file mode 100644 index 0000000..f43bc6b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/403df5a8764d001117ad98d4e911bb97 @@ -0,0 +1,238 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Node currentNode = head; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/406036f4764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/406036f4764d001117ad98d4e911bb97 new file mode 100644 index 0000000..e895c7a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/406036f4764d001117ad98d4e911bb97 @@ -0,0 +1,244 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/905aa1cbfd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/905aa1cbfd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..ab26fcf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/905aa1cbfd4d00111282df97d7c4d0e2 @@ -0,0 +1,421 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/30736f9f804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/30736f9f804d001117ad98d4e911bb97 new file mode 100644 index 0000000..bbe9fe3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/30736f9f804d001117ad98d4e911bb97 @@ -0,0 +1,354 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/609f941d5e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/609f941d5e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..67d4cc2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/609f941d5e4d001117ad98d4e911bb97 @@ -0,0 +1,231 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + return true; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/805ee151764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/805ee151764d001117ad98d4e911bb97 new file mode 100644 index 0000000..54d56f2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/805ee151764d001117ad98d4e911bb97 @@ -0,0 +1,232 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/d023eb9c344d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/d023eb9c344d0011135ca7e1c9885acd deleted file mode 100644 index 2102fe4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/d023eb9c344d0011135ca7e1c9885acd +++ /dev/null @@ -1,78 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - head.next.prev = null; - head = head.next; - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/10dd6882324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/10dd6882324d0011135ca7e1c9885acd deleted file mode 100644 index d57eb7d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/10dd6882324d0011135ca7e1c9885acd +++ /dev/null @@ -1,68 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/206bbf40fc4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/206bbf40fc4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..c0af408 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/206bbf40fc4d00111282df97d7c4d0e2 @@ -0,0 +1,411 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/309060ab2f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/309060ab2f4d0011135ca7e1c9885acd deleted file mode 100644 index ae4af8a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/309060ab2f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,52 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/709479b22f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/709479b22f4d0011135ca7e1c9885acd deleted file mode 100644 index 1864f09..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/709479b22f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,54 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/805f50da324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/805f50da324d0011135ca7e1c9885acd deleted file mode 100644 index 8a3c574..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/805f50da324d0011135ca7e1c9885acd +++ /dev/null @@ -1,77 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp; - if (size == 1) { - tmp = head.data; - head = tail = null; - } else { - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3e/90898c119f4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3e/90898c119f4c0011135ca7e1c9885acd deleted file mode 100644 index e69de29..0000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3e/a0183c26aa4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/3e/a0183c26aa4c0011135ca7e1c9885acd deleted file mode 100644 index 0c9e335..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3e/a0183c26aa4c0011135ca7e1c9885acd +++ /dev/null @@ -1,24 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - - protected static Map ContaDuplicati(BinaryNode node, ) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3f/90badac87b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/90badac87b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..bc8113e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/90badac87b4d001117ad98d4e911bb97 @@ -0,0 +1,290 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + return; + } + // Caso in cui sia l'ultimo + if (index == size) + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/40/b034c1e3a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/40/b034c1e3a94c0011135ca7e1c9885acd deleted file mode 100644 index 060f81e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/40/b034c1e3a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,20 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/40/c0d0bd0c1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/40/c0d0bd0c1e4d0011135ca7e1c9885acd deleted file mode 100644 index 5ef1a74..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/40/c0d0bd0c1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,7 +0,0 @@ -package list.mylinkedlist; - -public class MyLinkedList { - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/50cddb2d8f4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/42/50cddb2d8f4c0011135ca7e1c9885acd deleted file mode 100644 index 900cc71..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/42/50cddb2d8f4c0011135ca7e1c9885acd +++ /dev/null @@ -1,16 +0,0 @@ -package jcf_map.exercise; - -public class Dispari { - - /* - * Esercizio 1 - Esame del 5 settembre 2017 - * - * Una lista si dice dispari se ciascuno dei suoi oggetti appare un numero dispari di volte. - * Ad esempio, la lista di interi [20, 5, 5, 20, 20] non è dispari, mentre lo è [5, 20, 5 , 5]. - * Si assuma una classe Dispari con una sola variabile di instanza private LinkedList myList. - * Si implementi un metodo public boolean ordinaDispari() {} interno alla classe, - * che restituisce false se myLisy non è dispari, mentre ordina in modo crescente la lista - * e restituisce true se myList è dispari; - */ - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/504dba233a4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/42/50ef654f574d001117ad98d4e911bb97 similarity index 70% rename from .metadata/.plugins/org.eclipse.core.resources/.history/1c/504dba233a4d0011135ca7e1c9885acd rename to .metadata/.plugins/org.eclipse.core.resources/.history/42/50ef654f574d001117ad98d4e911bb97 index d80a225..c03bada 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/504dba233a4d0011135ca7e1c9885acd +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/42/50ef654f574d001117ad98d4e911bb97 @@ -4,7 +4,7 @@ import java.util.List; import java.util.NoSuchElementException; public class MyLinkedList implements List { - + /* * Classe Nodo */ @@ -128,15 +128,58 @@ public class MyLinkedList implements List { public void add(int index, E item) { if (item == null) throw new NullPointerException(); if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - + // Se l'inserimento è richiesto nella prima posizione if (index == 0) { addFirst(item); return; } - + // Se l'inserimento è richiesto nell'ultima posizione if (index == size) { - + addLast(item); + return; } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); } } diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/6029c9127d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/42/6029c9127d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..64e02e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/42/6029c9127d4d001117ad98d4e911bb97 @@ -0,0 +1,313 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/60a9a477a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/42/60a9a477a94c0011135ca7e1c9885acd deleted file mode 100644 index e62b7dd..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/42/60a9a477a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,13 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/801890d5574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/42/801890d5574d001117ad98d4e911bb97 new file mode 100644 index 0000000..1f57ab1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/42/801890d5574d001117ad98d4e911bb97 @@ -0,0 +1,191 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/80d89bf3774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/42/80d89bf3774d001117ad98d4e911bb97 new file mode 100644 index 0000000..47b3166 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/42/80d89bf3774d001117ad98d4e911bb97 @@ -0,0 +1,260 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/d0b42ef87c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/42/d0b42ef87c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..3fd542b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/42/d0b42ef87c4d001117ad98d4e911bb97 @@ -0,0 +1,307 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + public boolean hasNext() { + return next != null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/e0cbea023a4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/42/e0cbea023a4d0011135ca7e1c9885acd deleted file mode 100644 index b66d5ae..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/42/e0cbea023a4d0011135ca7e1c9885acd +++ /dev/null @@ -1,136 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - if (index == 0) { - addFirst(item); - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/43/10b441b1584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/43/10b441b1584d001117ad98d4e911bb97 new file mode 100644 index 0000000..ab20a0b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/43/10b441b1584d001117ad98d4e911bb97 @@ -0,0 +1,193 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + // Iterazione per la ricerca dell'oggetto + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/44/a04603031e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/44/a04603031e4d0011135ca7e1c9885acd deleted file mode 100644 index b2ee34c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/44/a04603031e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,5 +0,0 @@ -package list.mylinkedlist; - -public class MyLinkedList { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/44/f0005c81324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/44/f0005c81324d0011135ca7e1c9885acd deleted file mode 100644 index f975633..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/44/f0005c81324d0011135ca7e1c9885acd +++ /dev/null @@ -1,67 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/45/e05f32507f4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/45/e05f32507f4d001117ad98d4e911bb97 new file mode 100644 index 0000000..b21b7d3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/45/e05f32507f4d001117ad98d4e911bb97 @@ -0,0 +1,347 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/45/e08b33a77d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/45/e08b33a77d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..7b81a67 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/45/e08b33a77d4d001117ad98d4e911bb97 @@ -0,0 +1,319 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/46/80b1c7d6804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/46/80b1c7d6804d001117ad98d4e911bb97 new file mode 100644 index 0000000..5bc478d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/46/80b1c7d6804d001117ad98d4e911bb97 @@ -0,0 +1,359 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + + } + // Se l'ultimo elemento ad essere stato restituito è la coda + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/46/9009d050fa4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/46/9009d050fa4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..ba7cf43 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/46/9009d050fa4d00111282df97d7c4d0e2 @@ -0,0 +1,393 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + @Override + public void add(E data) { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/47/c011bffa7e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/47/c011bffa7e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..ea254e6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/47/c011bffa7e4d001117ad98d4e911bb97 @@ -0,0 +1,337 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/48/0075ba535a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/48/0075ba535a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..64a07e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/48/0075ba535a4d001117ad98d4e911bb97 @@ -0,0 +1,219 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + currentNode = currentNode.next; + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + } + } + size--; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/48/30deeb827e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/48/30deeb827e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..7e73493 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/48/30deeb827e4d001117ad98d4e911bb97 @@ -0,0 +1,324 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/48/5019b48d324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/48/5019b48d324d0011135ca7e1c9885acd deleted file mode 100644 index 45c9aeb..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/48/5019b48d324d0011135ca7e1c9885acd +++ /dev/null @@ -1,69 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/49/30ac4aba7e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/49/30ac4aba7e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..89a2f30 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/49/30ac4aba7e4d001117ad98d4e911bb97 @@ -0,0 +1,330 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/49/70bda109ff4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/49/70bda109ff4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..c16cbf0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/49/70bda109ff4d00111282df97d7c4d0e2 @@ -0,0 +1,437 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + @Override + public void set(E data) { + if (lastReturned == null) throw new NoSuchElementException(); + if (e == null) + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/49/d05f54f2344d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/49/d05f54f2344d0011135ca7e1c9885acd deleted file mode 100644 index 99167aa..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/49/d05f54f2344d0011135ca7e1c9885acd +++ /dev/null @@ -1,80 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/49/f06a35857c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/49/f06a35857c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..fcce37b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/49/f06a35857c4d001117ad98d4e911bb97 @@ -0,0 +1,300 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + posNext = 0; + while (posNext < index) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/801f58a5594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/801f58a5594d001117ad98d4e911bb97 new file mode 100644 index 0000000..9d6c65f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/801f58a5594d001117ad98d4e911bb97 @@ -0,0 +1,212 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/90995109aa4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/90995109aa4c0011135ca7e1c9885acd deleted file mode 100644 index 76c327d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/90995109aa4c0011135ca7e1c9885acd +++ /dev/null @@ -1,24 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - - protected static Map ContaDuplicati() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/a09dc134814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/a09dc134814d001117ad98d4e911bb97 new file mode 100644 index 0000000..681c762 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/a09dc134814d001117ad98d4e911bb97 @@ -0,0 +1,367 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + Node removingNode = head; + Node nextingNode = removingNode.next; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/b0fad96dfe4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/b0fad96dfe4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..0dda5c7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/b0fad96dfe4d00111282df97d7c4d0e2 @@ -0,0 +1,431 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + lastReturned = null; + posNext++; + size++; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/00ef1087fb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/00ef1087fb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..3beba8a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/00ef1087fb4d00111282df97d7c4d0e2 @@ -0,0 +1,405 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se la lista è vuota + if (size == 0) { + tail = head = new Node; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/4096a4f5764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/4096a4f5764d001117ad98d4e911bb97 new file mode 100644 index 0000000..9288d07 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/4096a4f5764d001117ad98d4e911bb97 @@ -0,0 +1,244 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/70645260794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/70645260794d001117ad98d4e911bb97 new file mode 100644 index 0000000..12be8e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/70645260794d001117ad98d4e911bb97 @@ -0,0 +1,275 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/801e556f394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/801e556f394d0011135ca7e1c9885acd deleted file mode 100644 index abc5aff..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/801e556f394d0011135ca7e1c9885acd +++ /dev/null @@ -1,132 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/8045cd9a374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/8045cd9a374d0011135ca7e1c9885acd deleted file mode 100644 index a18c0b0..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/8045cd9a374d0011135ca7e1c9885acd +++ /dev/null @@ -1,113 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(); - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/c0dc092bfc4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/c0dc092bfc4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..e12ba5c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/c0dc092bfc4d00111282df97d7c4d0e2 @@ -0,0 +1,410 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4c/d0bc35095d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4c/d0bc35095d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..6cb4a9e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4c/d0bc35095d4d001117ad98d4e911bb97 @@ -0,0 +1,222 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + } + return false; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4d/c0880dc5354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/4d/c0880dc5354d0011135ca7e1c9885acd deleted file mode 100644 index d963519..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4d/c0880dc5354d0011135ca7e1c9885acd +++ /dev/null @@ -1,90 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) return new NoSuchElementException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/0006cd1a814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/0006cd1a814d001117ad98d4e911bb97 new file mode 100644 index 0000000..5deb1e0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/0006cd1a814d001117ad98d4e911bb97 @@ -0,0 +1,366 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + Node rmNode = head; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/10000be77b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/10000be77b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..1c183a4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/10000be77b4d001117ad98d4e911bb97 @@ -0,0 +1,294 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = head; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/506489f1584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/506489f1584d001117ad98d4e911bb97 new file mode 100644 index 0000000..ff69d10 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/506489f1584d001117ad98d4e911bb97 @@ -0,0 +1,201 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + + if () + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/60f31582384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/60f31582384d0011135ca7e1c9885acd deleted file mode 100644 index 902662c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/60f31582384d0011135ca7e1c9885acd +++ /dev/null @@ -1,117 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/903e85f25a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/903e85f25a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..9ea642c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/903e85f25a4d001117ad98d4e911bb97 @@ -0,0 +1,193 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + while () + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/9083c736304d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/9083c736304d0011135ca7e1c9885acd deleted file mode 100644 index abb3deb..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/9083c736304d0011135ca7e1c9885acd +++ /dev/null @@ -1,59 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(null, null, item); - } else { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/d0ccc04afd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/d0ccc04afd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..65741dd --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/d0ccc04afd4d00111282df97d7c4d0e2 @@ -0,0 +1,412 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/e088d0d9794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/e088d0d9794d001117ad98d4e911bb97 new file mode 100644 index 0000000..d007832 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/e088d0d9794d001117ad98d4e911bb97 @@ -0,0 +1,283 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + nextNode = head; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/f05965a1374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/4f/f05965a1374d0011135ca7e1c9885acd deleted file mode 100644 index 6a1d0da..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4f/f05965a1374d0011135ca7e1c9885acd +++ /dev/null @@ -1,114 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(); - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5/10efa127fb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/5/10efa127fb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..df668a8 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5/10efa127fb4d00111282df97d7c4d0e2 @@ -0,0 +1,401 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5/30338771594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/5/30338771594d001117ad98d4e911bb97 new file mode 100644 index 0000000..c0f6439 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5/30338771594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5/307a86ee7c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/5/307a86ee7c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..a4083b9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5/307a86ee7c4d001117ad98d4e911bb97 @@ -0,0 +1,303 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5/504e5a3b814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/5/504e5a3b814d001117ad98d4e911bb97 new file mode 100644 index 0000000..ad2e3ec --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5/504e5a3b814d001117ad98d4e911bb97 @@ -0,0 +1,367 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst() + + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5/d00d46ae384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/5/d00d46ae384d0011135ca7e1c9885acd deleted file mode 100644 index 655dc1d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5/d00d46ae384d0011135ca7e1c9885acd +++ /dev/null @@ -1,119 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5/e0a2e6bc754d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/5/e0a2e6bc754d001117ad98d4e911bb97 new file mode 100644 index 0000000..42b7f7a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5/e0a2e6bc754d001117ad98d4e911bb97 @@ -0,0 +1,227 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/50/60160ff55d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/50/60160ff55d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..a1000e6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/50/60160ff55d4d001117ad98d4e911bb97 @@ -0,0 +1,227 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/50/60c2b7b97b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/50/60c2b7b97b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..b18256e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/50/60c2b7b97b4d001117ad98d4e911bb97 @@ -0,0 +1,287 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/50/703706531e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/50/703706531e4d0011135ca7e1c9885acd deleted file mode 100644 index 227720a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/50/703706531e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,17 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/52/20cb337d1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/52/20cb337d1e4d0011135ca7e1c9885acd deleted file mode 100644 index 29d369d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/52/20cb337d1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,26 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/54/009c5fde7b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/54/009c5fde7b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..5ff9a92 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/54/009c5fde7b4d001117ad98d4e911bb97 @@ -0,0 +1,294 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/54/109ff16f594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/54/109ff16f594d001117ad98d4e911bb97 new file mode 100644 index 0000000..80e862a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/54/109ff16f594d001117ad98d4e911bb97 @@ -0,0 +1,209 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/54/a0de835e7c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/54/a0de835e7c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..b7b8ca4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/54/a0de835e7c4d001117ad98d4e911bb97 @@ -0,0 +1,300 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + Node currentNode = head; + posNext = 0; + while (i < index) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/54/d03231a7394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/54/d03231a7394d0011135ca7e1c9885acd deleted file mode 100644 index 5a9410b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/54/d03231a7394d0011135ca7e1c9885acd +++ /dev/null @@ -1,134 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - if () - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/55/a069e620364d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/55/a069e620364d0011135ca7e1c9885acd deleted file mode 100644 index eff3716..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/55/a069e620364d0011135ca7e1c9885acd +++ /dev/null @@ -1,96 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/55/d0ac5eeefe4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/55/d0ac5eeefe4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..7827fc4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/55/d0ac5eeefe4d00111282df97d7c4d0e2 @@ -0,0 +1,436 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + @Override + public void set(E data) { + if (lastNode == null) throw new NoSuchElementException(); + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/56/00ccfe8f874d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/56/00ccfe8f874d001117ad98d4e911bb97 new file mode 100644 index 0000000..af7958a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/56/00ccfe8f874d001117ad98d4e911bb97 @@ -0,0 +1,388 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) size--; + + nextNode = nNode; + prevNode = pNode; + posNext--; + lastReturned = null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/56/506ddabe594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/56/506ddabe594d001117ad98d4e911bb97 new file mode 100644 index 0000000..9d6c65f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/56/506ddabe594d001117ad98d4e911bb97 @@ -0,0 +1,212 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/56/70d4e419774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/56/70d4e419774d001117ad98d4e911bb97 new file mode 100644 index 0000000..ae5bf7d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/56/70d4e419774d001117ad98d4e911bb97 @@ -0,0 +1,247 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/56/b0e86572804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/56/b0e86572804d001117ad98d4e911bb97 new file mode 100644 index 0000000..8edf9bf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/56/b0e86572804d001117ad98d4e911bb97 @@ -0,0 +1,350 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + @Override + public void remove() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/56/f0c2aadb804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/56/f0c2aadb804d001117ad98d4e911bb97 new file mode 100644 index 0000000..00aac72 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/56/f0c2aadb804d001117ad98d4e911bb97 @@ -0,0 +1,362 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/57/10a5470e1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/57/10a5470e1e4d0011135ca7e1c9885acd deleted file mode 100644 index 847ef07..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/57/10a5470e1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,9 +0,0 @@ -package list.mylinkedlist; - -public class MyLinkedList { - - /* - * Classe Nodo - */ - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/57/207d929e324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/57/207d929e324d0011135ca7e1c9885acd deleted file mode 100644 index 8197988..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/57/207d929e324d0011135ca7e1c9885acd +++ /dev/null @@ -1,71 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - if (size == 1) { - Node tmp = head; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/57/70762361814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/57/70762361814d001117ad98d4e911bb97 new file mode 100644 index 0000000..8b1cfdb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/57/70762361814d001117ad98d4e911bb97 @@ -0,0 +1,367 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/57/b0f539ae814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/57/b0f539ae814d001117ad98d4e911bb97 new file mode 100644 index 0000000..024ccfa --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/57/b0f539ae814d001117ad98d4e911bb97 @@ -0,0 +1,371 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5a/00dcb9c1584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/5a/00dcb9c1584d001117ad98d4e911bb97 new file mode 100644 index 0000000..cad6e71 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5a/00dcb9c1584d001117ad98d4e911bb97 @@ -0,0 +1,196 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + while (currentNode.next != null) { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5a/603b700d1f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/5a/603b700d1f4d0011135ca7e1c9885acd deleted file mode 100644 index e83a01e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5a/603b700d1f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,30 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5c/e09d79f1fd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/5c/e09d79f1fd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..cf00280 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5c/e09d79f1fd4d00111282df97d7c4d0e2 @@ -0,0 +1,426 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5d/40636b107d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/5d/40636b107d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..ebdc6a1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5d/40636b107d4d001117ad98d4e911bb97 @@ -0,0 +1,311 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + public boolean hasNext() { + return nextNode != null; + } + + public boolean hasPrevious() { + return prevNode != null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/e02bd5b0324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/5e/e02bd5b0324d0011135ca7e1c9885acd deleted file mode 100644 index 53570c7..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/e02bd5b0324d0011135ca7e1c9885acd +++ /dev/null @@ -1,73 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - if (size == 1) { - E tmp = head.data; - head = tail = null; - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5f/a0b241097c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/5f/a0b241097c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..5071d4c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5f/a0b241097c4d001117ad98d4e911bb97 @@ -0,0 +1,297 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + Node currentNode = head; + int i = 0; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6/70690d547a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/6/70690d547a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..2ada5b5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6/70690d547a4d001117ad98d4e911bb97 @@ -0,0 +1,288 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + lastReturned = head; + posNext = 0; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6/f03c9e905e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/6/f03c9e905e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..32e01c9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6/f03c9e905e4d001117ad98d4e911bb97 @@ -0,0 +1,236 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + return true; + } else return removeRec(head.next, object); + } + + private boolean removeRec(Node current, E object) { + if (current == null) return false; + if (current.data.equals(object)) + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/10fddfda794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/60/10fddfda794d001117ad98d4e911bb97 new file mode 100644 index 0000000..17703b8 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/60/10fddfda794d001117ad98d4e911bb97 @@ -0,0 +1,283 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/40d39f327a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/60/40d39f327a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..0484836 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/60/40d39f327a4d001117ad98d4e911bb97 @@ -0,0 +1,288 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + lastReturned = null; + posNext = 1; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/80cc47ab394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/60/80cc47ab394d0011135ca7e1c9885acd deleted file mode 100644 index 4863c28..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/60/80cc47ab394d0011135ca7e1c9885acd +++ /dev/null @@ -1,134 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - if (index ) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/a064d590814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/60/a064d590814d001117ad98d4e911bb97 new file mode 100644 index 0000000..016e649 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/60/a064d590814d001117ad98d4e911bb97 @@ -0,0 +1,370 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/f0b27634764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/60/f0b27634764d001117ad98d4e911bb97 new file mode 100644 index 0000000..e798f01 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/60/f0b27634764d001117ad98d4e911bb97 @@ -0,0 +1,232 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/61/a0b004fb5a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/61/a0b004fb5a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..44be72d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/61/a0b004fb5a4d001117ad98d4e911bb97 @@ -0,0 +1,193 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/62/30a390b9fb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/62/30a390b9fb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..22ce384 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/62/30a390b9fb4d00111282df97d7c4d0e2 @@ -0,0 +1,406 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se la lista è vuota + if (size == 0) { + tail = head = new Node(); + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/62/d08425b4314d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/62/d08425b4314d0011135ca7e1c9885acd deleted file mode 100644 index f02d40f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/62/d08425b4314d0011135ca7e1c9885acd +++ /dev/null @@ -1,61 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - head = newNode; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/63/10a2818c594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/63/10a2818c594d001117ad98d4e911bb97 new file mode 100644 index 0000000..63af56e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/63/10a2818c594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if () + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/63/40d1df262f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/63/40d1df262f4d0011135ca7e1c9885acd deleted file mode 100644 index 439a6b7..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/63/40d1df262f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,34 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/63/501b8f83374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/63/501b8f83374d0011135ca7e1c9885acd deleted file mode 100644 index 998fb4e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/63/501b8f83374d0011135ca7e1c9885acd +++ /dev/null @@ -1,113 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/63/80b84ffa5a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/63/80b84ffa5a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..0a99e80 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/63/80b84ffa5a4d001117ad98d4e911bb97 @@ -0,0 +1,193 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while () + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/64/20e64bf5fe4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/64/20e64bf5fe4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..0626c8c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/64/20e64bf5fe4d00111282df97d7c4d0e2 @@ -0,0 +1,436 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + @Override + public void set(E data) { + if (lastReturned == null) throw new NoSuchElementException(); + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/64/30067cc7814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/64/30067cc7814d001117ad98d4e911bb97 new file mode 100644 index 0000000..506eb0b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/64/30067cc7814d001117ad98d4e911bb97 @@ -0,0 +1,372 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/64/7099dc457a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/64/7099dc457a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..0ef3b1b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/64/7099dc457a4d001117ad98d4e911bb97 @@ -0,0 +1,288 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + lastReturned = null; + posNext = 0; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/64/e0b91ffd854d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/64/e0b91ffd854d001117ad98d4e911bb97 new file mode 100644 index 0000000..dfac56b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/64/e0b91ffd854d001117ad98d4e911bb97 @@ -0,0 +1,374 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/64/f02cfc58754d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/64/f02cfc58754d001117ad98d4e911bb97 new file mode 100644 index 0000000..378218e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/64/f02cfc58754d001117ad98d4e911bb97 @@ -0,0 +1,238 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + return true; + } else return removeRec(head.next, object); + } + + private boolean removeRec(Node current, E object) { + if (current == null) return false; + if (current.data.equals(object)) { + if (current == tail) removeLast(); + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/64/f0c0e5057d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/64/f0c0e5057d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..7dd6a81 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/64/f0c0e5057d4d001117ad98d4e911bb97 @@ -0,0 +1,311 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + public boolean hasNext() { + return nextNode != null; + } + + public boolean hasPrevious() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/65/7043ca16764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/65/7043ca16764d001117ad98d4e911bb97 new file mode 100644 index 0000000..2fd88b5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/65/7043ca16764d001117ad98d4e911bb97 @@ -0,0 +1,228 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/66/a06067fe7b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/66/a06067fe7b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..6ed4bd0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/66/a06067fe7b4d001117ad98d4e911bb97 @@ -0,0 +1,296 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + Node currentNode; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/67/e009c3f5a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/67/e009c3f5a94c0011135ca7e1c9885acd deleted file mode 100644 index 4ad9786..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/67/e009c3f5a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,22 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/69/a0785a011e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/69/a0785a011e4d0011135ca7e1c9885acd deleted file mode 100644 index e69de29..0000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/69/d0f50675324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/69/d0f50675324d0011135ca7e1c9885acd deleted file mode 100644 index e0d8fc3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/69/d0f50675324d0011135ca7e1c9885acd +++ /dev/null @@ -1,67 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/60be6d1b774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/6a/60be6d1b774d001117ad98d4e911bb97 new file mode 100644 index 0000000..2447bdc --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6a/60be6d1b774d001117ad98d4e911bb97 @@ -0,0 +1,249 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/90be0379354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/6a/90be0379354d0011135ca7e1c9885acd deleted file mode 100644 index 9dd4186..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/90be0379354d0011135ca7e1c9885acd +++ /dev/null @@ -1,85 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/e0fa43622f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/6a/e0fa43622f4d0011135ca7e1c9885acd deleted file mode 100644 index fc1f2a8..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/e0fa43622f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,44 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/50a69a65374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/6b/50a69a65374d0011135ca7e1c9885acd deleted file mode 100644 index c267135..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/50a69a65374d0011135ca7e1c9885acd +++ /dev/null @@ -1,108 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - if () - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/002d3cdb5c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/6d/002d3cdb5c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..2ce89bc --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6d/002d3cdb5c4d001117ad98d4e911bb97 @@ -0,0 +1,217 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/204cb9d82f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/6d/204cb9d82f4d0011135ca7e1c9885acd deleted file mode 100644 index aff4eee..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/204cb9d82f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,55 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/40a0f22eaa4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/6d/40a0f22eaa4c0011135ca7e1c9885acd deleted file mode 100644 index febf3d8..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/40a0f22eaa4c0011135ca7e1c9885acd +++ /dev/null @@ -1,25 +0,0 @@ -package jcf_map.exercise; - -import java.util.HashMap; -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - - protected static Map ContaDuplicati(BinaryNode node, HashMap mappa) { - if (node == nukk) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/b02166c3324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/6d/b02166c3324d0011135ca7e1c9885acd deleted file mode 100644 index 6d0a182..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/b02166c3324d0011135ca7e1c9885acd +++ /dev/null @@ -1,74 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp; - if (size == 1) { - tmp = head.data; - head = tail = null; - return tmp; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6e/704812b5764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/6e/704812b5764d001117ad98d4e911bb97 new file mode 100644 index 0000000..4050741 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6e/704812b5764d001117ad98d4e911bb97 @@ -0,0 +1,239 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + + Node currentNode = head; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7/501f12b3fd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/7/501f12b3fd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..1960f2c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/7/501f12b3fd4d00111282df97d7c4d0e2 @@ -0,0 +1,417 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7/80076b54324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/7/80076b54324d0011135ca7e1c9885acd deleted file mode 100644 index 3488c82..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7/80076b54324d0011135ca7e1c9885acd +++ /dev/null @@ -1,67 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if () - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7/b0c15931594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/7/b0c15931594d001117ad98d4e911bb97 new file mode 100644 index 0000000..5584397 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/7/b0c15931594d001117ad98d4e911bb97 @@ -0,0 +1,204 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/70/80c01fca354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/70/80c01fca354d0011135ca7e1c9885acd deleted file mode 100644 index 1ec2256..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/70/80c01fca354d0011135ca7e1c9885acd +++ /dev/null @@ -1,91 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/70/f0fb338d764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/70/f0fb338d764d001117ad98d4e911bb97 new file mode 100644 index 0000000..ac71801 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/70/f0fb338d764d001117ad98d4e911bb97 @@ -0,0 +1,237 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/71/306d19e8574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/71/306d19e8574d001117ad98d4e911bb97 new file mode 100644 index 0000000..9e101d7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/71/306d19e8574d001117ad98d4e911bb97 @@ -0,0 +1,192 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/71/70cdbd08fc4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/71/70cdbd08fc4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..773b14a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/71/70cdbd08fc4d00111282df97d7c4d0e2 @@ -0,0 +1,408 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/72/80ef576ffb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/72/80ef576ffb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..e02ab4d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/72/80ef576ffb4d00111282df97d7c4d0e2 @@ -0,0 +1,402 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/72/e04cece2774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/72/e04cece2774d001117ad98d4e911bb97 new file mode 100644 index 0000000..1b661ee --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/72/e04cece2774d001117ad98d4e911bb97 @@ -0,0 +1,255 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/70ae0a0b5e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/73/70ae0a0b5e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..ca7c829 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/73/70ae0a0b5e4d001117ad98d4e911bb97 @@ -0,0 +1,230 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/9018c15f874d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/73/9018c15f874d001117ad98d4e911bb97 new file mode 100644 index 0000000..42c8cf4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/73/9018c15f874d001117ad98d4e911bb97 @@ -0,0 +1,388 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) + + nextNode = nNode; + prevNode = pNode; + posNext--; + lastReturned = null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/b087ba94794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/73/b087ba94794d001117ad98d4e911bb97 new file mode 100644 index 0000000..6db0c20 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/73/b087ba94794d001117ad98d4e911bb97 @@ -0,0 +1,281 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || ) + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/74/902a2127304d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/74/902a2127304d0011135ca7e1c9885acd deleted file mode 100644 index 4c6a117..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/74/902a2127304d0011135ca7e1c9885acd +++ /dev/null @@ -1,59 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(); - } else { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/75/902a41b3794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/75/902a41b3794d001117ad98d4e911bb97 new file mode 100644 index 0000000..fb1e832 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/75/902a41b3794d001117ad98d4e911bb97 @@ -0,0 +1,281 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsExcpetion(); + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/76/3007bc09864d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/76/3007bc09864d001117ad98d4e911bb97 new file mode 100644 index 0000000..dfac56b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/76/3007bc09864d001117ad98d4e911bb97 @@ -0,0 +1,374 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/76/3023489d7c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/76/3023489d7c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..cc09deb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/76/3023489d7c4d001117ad98d4e911bb97 @@ -0,0 +1,302 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/76/304f2e47a84c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/76/304f2e47a84c0011135ca7e1c9885acd deleted file mode 100644 index 372bb1e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/76/304f2e47a84c0011135ca7e1c9885acd +++ /dev/null @@ -1,7 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - /* - * - */ -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/76/308d5f11ff4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/76/308d5f11ff4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..aa3442f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/76/308d5f11ff4d00111282df97d7c4d0e2 @@ -0,0 +1,437 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + @Override + public void set(E data) { + if (lastReturned == null) throw new NoSuchElementException(); + if (data == null) throw new NullPointerException(); + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/76/90a15fc1a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/76/90a15fc1a94c0011135ca7e1c9885acd deleted file mode 100644 index 6f72c9e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/76/90a15fc1a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,14 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/76/f0155bbd7d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/76/f0155bbd7d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..5129181 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/76/f0155bbd7d4d001117ad98d4e911bb97 @@ -0,0 +1,319 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/77/606dad7c7c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/77/606dad7c7c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..acd4f4c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/77/606dad7c7c4d001117ad98d4e911bb97 @@ -0,0 +1,300 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = + posNext = 0; + while (posNext < index) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/77/b06e0bee384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/77/b06e0bee384d0011135ca7e1c9885acd deleted file mode 100644 index 6701b51..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/77/b06e0bee384d0011135ca7e1c9885acd +++ /dev/null @@ -1,126 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/78/10c52150324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/78/10c52150324d0011135ca7e1c9885acd deleted file mode 100644 index f76b203..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/78/10c52150324d0011135ca7e1c9885acd +++ /dev/null @@ -1,63 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/78/901da8f7a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/78/901da8f7a94c0011135ca7e1c9885acd deleted file mode 100644 index d97c883..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/78/901da8f7a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,22 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - - protected static - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/78/d0591155574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/78/d0591155574d001117ad98d4e911bb97 new file mode 100644 index 0000000..8d9bc11 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/78/d0591155574d001117ad98d4e911bb97 @@ -0,0 +1,186 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/79/1093f429764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/79/1093f429764d001117ad98d4e911bb97 new file mode 100644 index 0000000..e70db81 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/79/1093f429764d001117ad98d4e911bb97 @@ -0,0 +1,232 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/79/201843157f4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/79/201843157f4d001117ad98d4e911bb97 new file mode 100644 index 0000000..47753af --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/79/201843157f4d001117ad98d4e911bb97 @@ -0,0 +1,345 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/79/c0797d61334d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/79/c0797d61334d0011135ca7e1c9885acd deleted file mode 100644 index 2db59ff..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/79/c0797d61334d0011135ca7e1c9885acd +++ /dev/null @@ -1,77 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - head.next.prev = null; - head.next = null; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7a/700c6bca584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/7a/700c6bca584d001117ad98d4e911bb97 new file mode 100644 index 0000000..562b2a2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/7a/700c6bca584d001117ad98d4e911bb97 @@ -0,0 +1,196 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7a/e0aef600fc4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/7a/e0aef600fc4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..d4e6c08 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/7a/e0aef600fc4d00111282df97d7c4d0e2 @@ -0,0 +1,408 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + size++; + prevNode = newNode; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7a/e0c9c2fe354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/7a/e0c9c2fe354d0011135ca7e1c9885acd deleted file mode 100644 index 454116e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7a/e0c9c2fe354d0011135ca7e1c9885acd +++ /dev/null @@ -1,92 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if () - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7b/908dc6ef774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/7b/908dc6ef774d001117ad98d4e911bb97 new file mode 100644 index 0000000..87e77ab --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/7b/908dc6ef774d001117ad98d4e911bb97 @@ -0,0 +1,256 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + r + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7b/c01006151f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/7b/c01006151f4d0011135ca7e1c9885acd deleted file mode 100644 index b91630b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7b/c01006151f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,32 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10d3ddbe354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10d3ddbe354d0011135ca7e1c9885acd deleted file mode 100644 index b46308c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10d3ddbe354d0011135ca7e1c9885acd +++ /dev/null @@ -1,90 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8/202e0ae85b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8/202e0ae85b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..77387a9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8/202e0ae85b4d001117ad98d4e911bb97 @@ -0,0 +1,213 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8/704d8dd0804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8/704d8dd0804d001117ad98d4e911bb97 new file mode 100644 index 0000000..202ca78 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8/704d8dd0804d001117ad98d4e911bb97 @@ -0,0 +1,358 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8/8021abdda94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/8/8021abdda94c0011135ca7e1c9885acd deleted file mode 100644 index 236ab7b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8/8021abdda94c0011135ca7e1c9885acd +++ /dev/null @@ -1,18 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8/a07d29e9574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8/a07d29e9574d001117ad98d4e911bb97 new file mode 100644 index 0000000..9e101d7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8/a07d29e9574d001117ad98d4e911bb97 @@ -0,0 +1,192 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/80/40df10af354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/80/40df10af354d0011135ca7e1c9885acd deleted file mode 100644 index f023c98..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/80/40df10af354d0011135ca7e1c9885acd +++ /dev/null @@ -1,88 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/81/50996eb9584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/81/50996eb9584d001117ad98d4e911bb97 new file mode 100644 index 0000000..5594827 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/81/50996eb9584d001117ad98d4e911bb97 @@ -0,0 +1,196 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + while () { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/82/30a092198f4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/82/30a092198f4c0011135ca7e1c9885acd deleted file mode 100644 index e64547d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/82/30a092198f4c0011135ca7e1c9885acd +++ /dev/null @@ -1,11 +0,0 @@ -package jcf_map.exercise; - -public class Dispari { - - /* - * Esercizio 1 - Esame del 5 settembre 2017 - * - * - */ - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/82/30d8d284324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/82/30d8d284324d0011135ca7e1c9885acd deleted file mode 100644 index 45c9aeb..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/82/30d8d284324d0011135ca7e1c9885acd +++ /dev/null @@ -1,69 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/82/b06d14245a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/82/b06d14245a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..bdadade --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/82/b06d14245a4d001117ad98d4e911bb97 @@ -0,0 +1,218 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/82/c0cc9810394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/82/c0cc9810394d0011135ca7e1c9885acd deleted file mode 100644 index 1b8c7d6..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/82/c0cc9810394d0011135ca7e1c9885acd +++ /dev/null @@ -1,130 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/82/d0a1113b5b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/82/d0a1113b5b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..f76ca5b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/82/d0a1113b5b4d001117ad98d4e911bb97 @@ -0,0 +1,200 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == ) + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/83/301f3bfb344d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/83/301f3bfb344d0011135ca7e1c9885acd deleted file mode 100644 index edbc633..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/83/301f3bfb344d0011135ca7e1c9885acd +++ /dev/null @@ -1,82 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/83/3082c0757c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/83/3082c0757c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..23973ee --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/83/3082c0757c4d001117ad98d4e911bb97 @@ -0,0 +1,300 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + Node currentNode = head; + posNext = 0; + while (posNext < index) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/84/6078c653594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/84/6078c653594d001117ad98d4e911bb97 new file mode 100644 index 0000000..080a302 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/84/6078c653594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/86/90914b937d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/86/90914b937d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..5d5064c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/86/90914b937d4d001117ad98d4e911bb97 @@ -0,0 +1,318 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/86/c04515591e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/86/c04515591e4d0011135ca7e1c9885acd deleted file mode 100644 index 011eb11..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/86/c04515591e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,19 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/87/f003fd11764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/87/f003fd11764d001117ad98d4e911bb97 new file mode 100644 index 0000000..8a431ec --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/87/f003fd11764d001117ad98d4e911bb97 @@ -0,0 +1,228 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null) return false; + Node currentNode = + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0bdef22774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0bdef22774d001117ad98d4e911bb97 new file mode 100644 index 0000000..69fcd95 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0bdef22774d001117ad98d4e911bb97 @@ -0,0 +1,251 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/89/7039b5ae2f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/89/7039b5ae2f4d0011135ca7e1c9885acd deleted file mode 100644 index 1864f09..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/89/7039b5ae2f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,54 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8a/a059850e874d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/a059850e874d001117ad98d4e911bb97 new file mode 100644 index 0000000..adba154 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/a059850e874d001117ad98d4e911bb97 @@ -0,0 +1,385 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + size--; + nextNode = nNode; + prevNode = pNode; + posNext--; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8a/e0acef47784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/e0acef47784d001117ad98d4e911bb97 new file mode 100644 index 0000000..4b58581 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/e0acef47784d001117ad98d4e911bb97 @@ -0,0 +1,265 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8b/202f8972334d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/8b/202f8972334d0011135ca7e1c9885acd deleted file mode 100644 index 8e41e06..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8b/202f8972334d0011135ca7e1c9885acd +++ /dev/null @@ -1,77 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - head.next.prev = null; - head = head.next; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8b/20435a372f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/8b/20435a372f4d0011135ca7e1c9885acd deleted file mode 100644 index df92adb..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8b/20435a372f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,36 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8b/d057f7a57c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8b/d057f7a57c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..b62eff0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8b/d057f7a57c4d001117ad98d4e911bb97 @@ -0,0 +1,302 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8c/5059e604304d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/8c/5059e604304d0011135ca7e1c9885acd deleted file mode 100644 index d0acc3d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8c/5059e604304d0011135ca7e1c9885acd +++ /dev/null @@ -1,55 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/600dc8273a4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/8c/a038bd36574d001117ad98d4e911bb97 similarity index 72% rename from .metadata/.plugins/org.eclipse.core.resources/.history/2e/600dc8273a4d0011135ca7e1c9885acd rename to .metadata/.plugins/org.eclipse.core.resources/.history/8c/a038bd36574d001117ad98d4e911bb97 index 8d5eb6d..f5bba55 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/600dc8273a4d0011135ca7e1c9885acd +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8c/a038bd36574d001117ad98d4e911bb97 @@ -4,7 +4,7 @@ import java.util.List; import java.util.NoSuchElementException; public class MyLinkedList implements List { - + /* * Classe Nodo */ @@ -128,16 +128,56 @@ public class MyLinkedList implements List { public void add(int index, E item) { if (item == null) throw new NullPointerException(); if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - + // Se l'inserimento è richiesto nella prima posizione if (index == 0) { addFirst(item); return; } - + // Se l'inserimento è richiesto nell'ultima posizione if (index == size) { addLast(item); return; } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; } + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + + } diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8d/10b4acbefd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/8d/10b4acbefd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..4c66a99 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8d/10b4acbefd4d00111282df97d7c4d0e2 @@ -0,0 +1,421 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(); + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8d/20777285804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8d/20777285804d001117ad98d4e911bb97 new file mode 100644 index 0000000..c230714 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8d/20777285804d001117ad98d4e911bb97 @@ -0,0 +1,354 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8d/b0caf323784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8d/b0caf323784d001117ad98d4e911bb97 new file mode 100644 index 0000000..37bc607 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8d/b0caf323784d001117ad98d4e911bb97 @@ -0,0 +1,261 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8e/c0278903874d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/c0278903874d001117ad98d4e911bb97 new file mode 100644 index 0000000..09dfb1a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/c0278903874d001117ad98d4e911bb97 @@ -0,0 +1,385 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + size--; + nextNode = nNode; + prevNode = pNode; + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8e/c0fb04fb7b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/c0fb04fb7b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..1d39b1a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/c0fb04fb7b4d001117ad98d4e911bb97 @@ -0,0 +1,296 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/41/e092d7263a4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/d0f40741574d001117ad98d4e911bb97 similarity index 70% rename from .metadata/.plugins/org.eclipse.core.resources/.history/41/e092d7263a4d0011135ca7e1c9885acd rename to .metadata/.plugins/org.eclipse.core.resources/.history/8e/d0f40741574d001117ad98d4e911bb97 index 0979822..f81f281 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/41/e092d7263a4d0011135ca7e1c9885acd +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/d0f40741574d001117ad98d4e911bb97 @@ -4,7 +4,7 @@ import java.util.List; import java.util.NoSuchElementException; public class MyLinkedList implements List { - + /* * Classe Nodo */ @@ -128,15 +128,58 @@ public class MyLinkedList implements List { public void add(int index, E item) { if (item == null) throw new NullPointerException(); if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - + // Se l'inserimento è richiesto nella prima posizione if (index == 0) { addFirst(item); return; } - + // Se l'inserimento è richiesto nell'ultima posizione if (index == size) { - addLast(); + addLast(item); + return; } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + } } diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/a0eb0f94804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9/a0eb0f94804d001117ad98d4e911bb97 new file mode 100644 index 0000000..afeed12 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9/a0eb0f94804d001117ad98d4e911bb97 @@ -0,0 +1,354 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastNode == null) + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/b07c5d4d794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9/b07c5d4d794d001117ad98d4e911bb97 new file mode 100644 index 0000000..a7ff156 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9/b07c5d4d794d001117ad98d4e911bb97 @@ -0,0 +1,273 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext = 0; + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/b0adb98f7c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9/b0adb98f7c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..a3381f9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9/b0adb98f7c4d001117ad98d4e911bb97 @@ -0,0 +1,301 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/f09fe899394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/9/f09fe899394d0011135ca7e1c9885acd deleted file mode 100644 index dccb934..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9/f09fe899394d0011135ca7e1c9885acd +++ /dev/null @@ -1,134 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/90/301ef4e2fd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/90/301ef4e2fd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..cf00280 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/90/301ef4e2fd4d00111282df97d7c4d0e2 @@ -0,0 +1,426 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/90/604506b6764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/90/604506b6764d001117ad98d4e911bb97 new file mode 100644 index 0000000..8e2e8bd --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/90/604506b6764d001117ad98d4e911bb97 @@ -0,0 +1,239 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object()[]; + Node currentNode = head; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/91/400ac96f1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/91/400ac96f1e4d0011135ca7e1c9885acd deleted file mode 100644 index 357845c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/91/400ac96f1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,24 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/91/509455cd7b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/91/509455cd7b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..7fd1afb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/91/509455cd7b4d001117ad98d4e911bb97 @@ -0,0 +1,292 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/91/b0cc65f27b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/91/b0cc65f27b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..6f68a15 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/91/b0cc65f27b4d001117ad98d4e911bb97 @@ -0,0 +1,295 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/91/b0d32432764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/91/b0d32432764d001117ad98d4e911bb97 new file mode 100644 index 0000000..fe5c34f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/91/b0d32432764d001117ad98d4e911bb97 @@ -0,0 +1,232 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if () + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/92/60198f872f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/92/60198f872f4d0011135ca7e1c9885acd deleted file mode 100644 index 08fe111..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/92/60198f872f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,48 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/93/20801486574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/93/20801486574d001117ad98d4e911bb97 new file mode 100644 index 0000000..9324c8e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/93/20801486574d001117ad98d4e911bb97 @@ -0,0 +1,187 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/93/f02274affb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/93/f02274affb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..7f1ead0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/93/f02274affb4d00111282df97d7c4d0e2 @@ -0,0 +1,405 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se la lista è vuota + if (size == 0) { + tail = head = new Node(); + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/94/70730e55324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/94/70730e55324d0011135ca7e1c9885acd deleted file mode 100644 index efde3f2..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/94/70730e55324d0011135ca7e1c9885acd +++ /dev/null @@ -1,67 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/94/c09467597c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/94/c09467597c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..ab56193 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/94/c09467597c4d001117ad98d4e911bb97 @@ -0,0 +1,300 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + Node currentNode = head; + int i = 0; + while (i < index) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/95/005505615e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/95/005505615e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..62a3c94 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/95/005505615e4d001117ad98d4e911bb97 @@ -0,0 +1,235 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + return true; + } else return removeRec(); + } + + private boolean removeRec(Node cur, E object) { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/95/40f5b996394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/95/40f5b996394d0011135ca7e1c9885acd deleted file mode 100644 index 065af6a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/95/40f5b996394d0011135ca7e1c9885acd +++ /dev/null @@ -1,133 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/95/60026996764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/95/60026996764d001117ad98d4e911bb97 new file mode 100644 index 0000000..0e059c7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/95/60026996764d001117ad98d4e911bb97 @@ -0,0 +1,238 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/95/d04dec0a5a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/95/d04dec0a5a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..1e440d1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/95/d04dec0a5a4d001117ad98d4e911bb97 @@ -0,0 +1,216 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/96/1067edbb7b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/96/1067edbb7b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..c65af8e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/96/1067edbb7b4d001117ad98d4e911bb97 @@ -0,0 +1,289 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + } + // Caso in cui sia l'ultimo + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/96/509f2670394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/96/509f2670394d0011135ca7e1c9885acd deleted file mode 100644 index c4922c4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/96/509f2670394d0011135ca7e1c9885acd +++ /dev/null @@ -1,132 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/97/906ae3e1864d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/97/906ae3e1864d001117ad98d4e911bb97 new file mode 100644 index 0000000..daa95b2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/97/906ae3e1864d001117ad98d4e911bb97 @@ -0,0 +1,381 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/97/f0cfaa937a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/97/f0cfaa937a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..4afa1e9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/97/f0cfaa937a4d001117ad98d4e911bb97 @@ -0,0 +1,288 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + lastReturned = head; + posNext = 1; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/98/c0e24a91814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/98/c0e24a91814d001117ad98d4e911bb97 new file mode 100644 index 0000000..75fde4d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/98/c0e24a91814d001117ad98d4e911bb97 @@ -0,0 +1,370 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/98/d0fab725764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/98/d0fab725764d001117ad98d4e911bb97 new file mode 100644 index 0000000..b235075 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/98/d0fab725764d001117ad98d4e911bb97 @@ -0,0 +1,231 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/99/00d747a7584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/99/00d747a7584d001117ad98d4e911bb97 new file mode 100644 index 0000000..9e101d7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/99/00d747a7584d001117ad98d4e911bb97 @@ -0,0 +1,192 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9a/f04ca058574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9a/f04ca058574d001117ad98d4e911bb97 new file mode 100644 index 0000000..65703b6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9a/f04ca058574d001117ad98d4e911bb97 @@ -0,0 +1,187 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return resul.toString(); + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9b/608ec5a8fd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/9b/608ec5a8fd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..57721c4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9b/608ec5a8fd4d00111282df97d7c4d0e2 @@ -0,0 +1,415 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9b/809e7b322f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/9b/809e7b322f4d0011135ca7e1c9885acd deleted file mode 100644 index 9865ad7..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9b/809e7b322f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,37 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/8024b776fb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/8024b776fb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..dfa8b3e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/8024b776fb4d00111282df97d7c4d0e2 @@ -0,0 +1,402 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/a0af664f784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/a0af664f784d001117ad98d4e911bb97 new file mode 100644 index 0000000..016ff52 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/a0af664f784d001117ad98d4e911bb97 @@ -0,0 +1,267 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/d0063f717e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/d0063f717e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..ef90512 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/d0063f717e4d001117ad98d4e911bb97 @@ -0,0 +1,325 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + return data; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9d/30b44c62814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9d/30b44c62814d001117ad98d4e911bb97 new file mode 100644 index 0000000..7c55020 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9d/30b44c62814d001117ad98d4e911bb97 @@ -0,0 +1,367 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9d/60b5b235764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9d/60b5b235764d001117ad98d4e911bb97 new file mode 100644 index 0000000..89173c2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9d/60b5b235764d001117ad98d4e911bb97 @@ -0,0 +1,232 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9e/a0672cfb804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9e/a0672cfb804d001117ad98d4e911bb97 new file mode 100644 index 0000000..2a31dcb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9e/a0672cfb804d001117ad98d4e911bb97 @@ -0,0 +1,366 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9e/a0afe3437a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/9e/a0afe3437a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..027add7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9e/a0afe3437a4d001117ad98d4e911bb97 @@ -0,0 +1,288 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + lastReturned = null; + posNext = 0; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/107553371e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/107553371e4d0011135ca7e1c9885acd deleted file mode 100644 index 62423f1..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/107553371e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,16 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/70a76b77fb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/70a76b77fb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..f1e8f18 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/70a76b77fb4d00111282df97d7c4d0e2 @@ -0,0 +1,402 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se la lista è vuota + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/a0ee9f5d794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/a0ee9f5d794d001117ad98d4e911bb97 new file mode 100644 index 0000000..6c260df --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/a0ee9f5d794d001117ad98d4e911bb97 @@ -0,0 +1,275 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a1/b0b7f7e8354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/a1/b0b7f7e8354d0011135ca7e1c9885acd deleted file mode 100644 index da3bd30..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a1/b0b7f7e8354d0011135ca7e1c9885acd +++ /dev/null @@ -1,91 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a1/d033c4cb584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a1/d033c4cb584d001117ad98d4e911bb97 new file mode 100644 index 0000000..29fb7af --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a1/d033c4cb584d001117ad98d4e911bb97 @@ -0,0 +1,197 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a2/d0a7910ffb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/a2/d0a7910ffb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..a90055e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a2/d0a7910ffb4d00111282df97d7c4d0e2 @@ -0,0 +1,397 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/15/d05528283a4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/a3/4062f45e514d001117ad98d4e911bb97 similarity index 72% rename from .metadata/.plugins/org.eclipse.core.resources/.history/15/d05528283a4d0011135ca7e1c9885acd rename to .metadata/.plugins/org.eclipse.core.resources/.history/a3/4062f45e514d001117ad98d4e911bb97 index 51cd951..3137bcb 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/15/d05528283a4d0011135ca7e1c9885acd +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a3/4062f45e514d001117ad98d4e911bb97 @@ -4,7 +4,7 @@ import java.util.List; import java.util.NoSuchElementException; public class MyLinkedList implements List { - + /* * Classe Nodo */ @@ -128,17 +128,56 @@ public class MyLinkedList implements List { public void add(int index, E item) { if (item == null) throw new NullPointerException(); if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - + // Se l'inserimento è richiesto nella prima posizione if (index == 0) { addFirst(item); return; } - + // Se l'inserimento è richiesto nell'ultima posizione if (index == size) { addLast(item); return; } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; } + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + + } diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/d06318c5a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/d06318c5a94c0011135ca7e1c9885acd deleted file mode 100644 index 383ea19..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/d06318c5a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,16 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a5/5059fde2764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/5059fde2764d001117ad98d4e911bb97 new file mode 100644 index 0000000..a259db4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/5059fde2764d001117ad98d4e911bb97 @@ -0,0 +1,241 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a5/508416ad814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/508416ad814d001117ad98d4e911bb97 new file mode 100644 index 0000000..3388a3b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/508416ad814d001117ad98d4e911bb97 @@ -0,0 +1,371 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a5/603da8ee584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/603da8ee584d001117ad98d4e911bb97 new file mode 100644 index 0000000..03e6309 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/603da8ee584d001117ad98d4e911bb97 @@ -0,0 +1,197 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + if () + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a5/80cdd584764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/80cdd584764d001117ad98d4e911bb97 new file mode 100644 index 0000000..be7ada1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/80cdd584764d001117ad98d4e911bb97 @@ -0,0 +1,237 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a6/f082faba784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a6/f082faba784d001117ad98d4e911bb97 new file mode 100644 index 0000000..b2369a1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a6/f082faba784d001117ad98d4e911bb97 @@ -0,0 +1,270 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a01417d4794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a01417d4794d001117ad98d4e911bb97 new file mode 100644 index 0000000..65c2dda --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a01417d4794d001117ad98d4e911bb97 @@ -0,0 +1,283 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/b05fc276a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/a7/b05fc276a94c0011135ca7e1c9885acd deleted file mode 100644 index 623bca4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/b05fc276a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,12 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a8/30e19efa1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/a8/30e19efa1e4d0011135ca7e1c9885acd deleted file mode 100644 index 7a3a6fc..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a8/30e19efa1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,30 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a8/a014b2c37b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a8/a014b2c37b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..45fd79c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a8/a014b2c37b4d001117ad98d4e911bb97 @@ -0,0 +1,289 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + } + // Caso in cui sia l'ultimo + if () + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a8/e08a5293874d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a8/e08a5293874d001117ad98d4e911bb97 new file mode 100644 index 0000000..929e1d2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a8/e08a5293874d001117ad98d4e911bb97 @@ -0,0 +1,388 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a9/105caa031e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/a9/105caa031e4d0011135ca7e1c9885acd deleted file mode 100644 index 6adc77a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a9/105caa031e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,5 +0,0 @@ -package list.mylinkedlist; - -public class MyLinkedList { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a9/502e6960594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/a9/502e6960594d001117ad98d4e911bb97 new file mode 100644 index 0000000..76e80a7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a9/502e6960594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi in mezzo + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/c05006351e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/aa/c05006351e4d0011135ca7e1c9885acd deleted file mode 100644 index ed24e75..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/c05006351e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,14 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/c068bd71354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/aa/c068bd71354d0011135ca7e1c9885acd deleted file mode 100644 index e745a33..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/c068bd71354d0011135ca7e1c9885acd +++ /dev/null @@ -1,85 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if () - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ac/d0db81781e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ac/d0db81781e4d0011135ca7e1c9885acd deleted file mode 100644 index 7cae160..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ac/d0db81781e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,26 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node() { - - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ac/f01b6fc6324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ac/f01b6fc6324d0011135ca7e1c9885acd deleted file mode 100644 index 732351f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ac/f01b6fc6324d0011135ca7e1c9885acd +++ /dev/null @@ -1,78 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp; - if (size == 1) { - tmp = head.data; - head = tail = null; - return tmp; - } else { - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ad/700a24cc814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ad/700a24cc814d001117ad98d4e911bb97 new file mode 100644 index 0000000..a33981e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ad/700a24cc814d001117ad98d4e911bb97 @@ -0,0 +1,373 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ae/20bcc8d9364d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ae/20bcc8d9364d0011135ca7e1c9885acd deleted file mode 100644 index 6133419..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ae/20bcc8d9364d0011135ca7e1c9885acd +++ /dev/null @@ -1,98 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ae/a0c7558e1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ae/a0c7558e1e4d0011135ca7e1c9885acd deleted file mode 100644 index f485d71..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ae/a0c7558e1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,28 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c0df257e804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c0df257e804d001117ad98d4e911bb97 new file mode 100644 index 0000000..eb1ab48 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c0df257e804d001117ad98d4e911bb97 @@ -0,0 +1,353 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/af/307c879a324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/af/307c879a324d0011135ca7e1c9885acd deleted file mode 100644 index d02f5c2..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/af/307c879a324d0011135ca7e1c9885acd +++ /dev/null @@ -1,71 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - if (size == 1) { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b/9091056f7e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b/9091056f7e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..59b5bf4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b/9091056f7e4d001117ad98d4e911bb97 @@ -0,0 +1,324 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + return data; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b/d027169ffd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/b/d027169ffd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..5e4d1e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b/d027169ffd4d00111282df97d7c4d0e2 @@ -0,0 +1,414 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/a0154147314d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/a0154147314d0011135ca7e1c9885acd deleted file mode 100644 index 7605e40..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/a0154147314d0011135ca7e1c9885acd +++ /dev/null @@ -1,59 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/a032422b7f4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/a032422b7f4d001117ad98d4e911bb97 new file mode 100644 index 0000000..dad6301 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/a032422b7f4d001117ad98d4e911bb97 @@ -0,0 +1,345 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b1/006d098e794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b1/006d098e794d001117ad98d4e911bb97 new file mode 100644 index 0000000..ec60700 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b1/006d098e794d001117ad98d4e911bb97 @@ -0,0 +1,281 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/40ccf410354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/40ccf410354d0011135ca7e1c9885acd deleted file mode 100644 index 9fa7f5d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/40ccf410354d0011135ca7e1c9885acd +++ /dev/null @@ -1,81 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60dbd5067f4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60dbd5067f4d001117ad98d4e911bb97 new file mode 100644 index 0000000..117a895 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60dbd5067f4d001117ad98d4e911bb97 @@ -0,0 +1,340 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/f03ebcd07b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/f03ebcd07b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..312cbf5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/f03ebcd07b4d001117ad98d4e911bb97 @@ -0,0 +1,292 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/8026f497874d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/8026f497874d001117ad98d4e911bb97 new file mode 100644 index 0000000..884c86e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/8026f497874d001117ad98d4e911bb97 @@ -0,0 +1,390 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/90de2ed2774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/90de2ed2774d001117ad98d4e911bb97 new file mode 100644 index 0000000..6fe4e21 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/90de2ed2774d001117ad98d4e911bb97 @@ -0,0 +1,253 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/e088ddff5a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/e088ddff5a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..79d4c9a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/e088ddff5a4d001117ad98d4e911bb97 @@ -0,0 +1,195 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/2004e3a3374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/2004e3a3374d0011135ca7e1c9885acd deleted file mode 100644 index 2b4ec16..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/2004e3a3374d0011135ca7e1c9885acd +++ /dev/null @@ -1,114 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node newNode = newNode; - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(); - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/30129ddc804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/30129ddc804d001117ad98d4e911bb97 new file mode 100644 index 0000000..5504189 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/30129ddc804d001117ad98d4e911bb97 @@ -0,0 +1,363 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + } + // Se è un elemento generico + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b5/70084afa344d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/b5/70084afa344d0011135ca7e1c9885acd deleted file mode 100644 index ab2dc78..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b5/70084afa344d0011135ca7e1c9885acd +++ /dev/null @@ -1,81 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b5/e0d76a61fe4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/b5/e0d76a61fe4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..956f8e3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b5/e0d76a61fe4d00111282df97d7c4d0e2 @@ -0,0 +1,431 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = nextNode; + newNode.next = prevNode; + prevNode.next = newNode; + lastReturned = null; + posNext++; + size++; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b6/f0bb64f85b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b6/f0bb64f85b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..1e9cf2e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b6/f0bb64f85b4d001117ad98d4e911bb97 @@ -0,0 +1,218 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b7/30cb4ab9384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/b7/30cb4ab9384d0011135ca7e1c9885acd deleted file mode 100644 index 8d2fa0a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b7/30cb4ab9384d0011135ca7e1c9885acd +++ /dev/null @@ -1,121 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/6052de592f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/b8/6052de592f4d0011135ca7e1c9885acd deleted file mode 100644 index 45c93d7..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/6052de592f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,40 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/70bf12691e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/b8/70bf12691e4d0011135ca7e1c9885acd deleted file mode 100644 index 7eb4c8f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/70bf12691e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,21 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b9/406d42d37e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/b9/406d42d37e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..6f3f56d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b9/406d42d37e4d001117ad98d4e911bb97 @@ -0,0 +1,331 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b9/b0ce8fb82f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/b9/b0ce8fb82f4d0011135ca7e1c9885acd deleted file mode 100644 index c7da99f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b9/b0ce8fb82f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,54 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ba/4080dec77b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ba/4080dec77b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..a2c2ec2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ba/4080dec77b4d001117ad98d4e911bb97 @@ -0,0 +1,290 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + return; + } + // Caso in cui sia l'ultimo + if () + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ba/9040418b5e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ba/9040418b5e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..8d91f69 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ba/9040418b5e4d001117ad98d4e911bb97 @@ -0,0 +1,235 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + return true; + } else return removeRec(head.next, object); + } + + private boolean removeRec(Node current, E object) { + if (current == null) return false; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ba/e028bda0804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ba/e028bda0804d001117ad98d4e911bb97 new file mode 100644 index 0000000..e9aa574 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ba/e028bda0804d001117ad98d4e911bb97 @@ -0,0 +1,355 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bb/007503241e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/bb/007503241e4d0011135ca7e1c9885acd deleted file mode 100644 index b868b49..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bb/007503241e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,10 +0,0 @@ -package list.mylinkedlist; - -public class MyLinkedList { - - /* - * Classe Nodo - */ - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bb/60487d22594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/bb/60487d22594d001117ad98d4e911bb97 new file mode 100644 index 0000000..8f5ef50 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bb/60487d22594d001117ad98d4e911bb97 @@ -0,0 +1,201 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/203da234314d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/203da234314d0011135ca7e1c9885acd deleted file mode 100644 index 30f3698..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/203da234314d0011135ca7e1c9885acd +++ /dev/null @@ -1,59 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/60c48dc5794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/60c48dc5794d001117ad98d4e911bb97 new file mode 100644 index 0000000..b374d86 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/60c48dc5794d001117ad98d4e911bb97 @@ -0,0 +1,282 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/a0eea647794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/a0eea647794d001117ad98d4e911bb97 new file mode 100644 index 0000000..da2a87d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/a0eea647794d001117ad98d4e911bb97 @@ -0,0 +1,273 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode = null; + private Node lastReturned = null; + private int posNext = 0; + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0fb6ef6354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0fb6ef6354d0011135ca7e1c9885acd deleted file mode 100644 index 561147c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0fb6ef6354d0011135ca7e1c9885acd +++ /dev/null @@ -1,92 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/20eadfba384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/bd/20eadfba384d0011135ca7e1c9885acd deleted file mode 100644 index befc509..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/20eadfba384d0011135ca7e1c9885acd +++ /dev/null @@ -1,122 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/be/30d58f43784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/be/30d58f43784d001117ad98d4e911bb97 new file mode 100644 index 0000000..f9294ae --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/be/30d58f43784d001117ad98d4e911bb97 @@ -0,0 +1,265 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator() { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/be/8004ad075e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/be/8004ad075e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..8850179 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/be/8004ad075e4d001117ad98d4e911bb97 @@ -0,0 +1,230 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bf/706659f75b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/bf/706659f75b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..f1e0667 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bf/706659f75b4d001117ad98d4e911bb97 @@ -0,0 +1,216 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bf/d0001202764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/bf/d0001202764d001117ad98d4e911bb97 new file mode 100644 index 0000000..949a6a0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bf/d0001202764d001117ad98d4e911bb97 @@ -0,0 +1,228 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null) return false; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/5009faf9584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/5009faf9584d001117ad98d4e911bb97 new file mode 100644 index 0000000..fa62541 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/5009faf9584d001117ad98d4e911bb97 @@ -0,0 +1,201 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + node = head; + if () + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/505e349c314d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/505e349c314d0011135ca7e1c9885acd deleted file mode 100644 index f7b6838..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/505e349c314d0011135ca7e1c9885acd +++ /dev/null @@ -1,60 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6085b9c7764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6085b9c7764d001117ad98d4e911bb97 new file mode 100644 index 0000000..65f3786 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6085b9c7764d001117ad98d4e911bb97 @@ -0,0 +1,241 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/90cca37b2f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/90cca37b2f4d0011135ca7e1c9885acd deleted file mode 100644 index fa7ea8b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/90cca37b2f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,48 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/f0531afb384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/f0531afb384d0011135ca7e1c9885acd deleted file mode 100644 index 51e7a60..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/f0531afb384d0011135ca7e1c9885acd +++ /dev/null @@ -1,128 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/501c44aa324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c1/501c44aa324d0011135ca7e1c9885acd deleted file mode 100644 index 5938a4b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/501c44aa324d0011135ca7e1c9885acd +++ /dev/null @@ -1,72 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - if (size == 1) { - Node tmp = head; - head = tail = null; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/600c34831e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c1/600c34831e4d0011135ca7e1c9885acd deleted file mode 100644 index 6955e86..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/600c34831e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,26 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/b0f50722774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c1/b0f50722774d001117ad98d4e911bb97 new file mode 100644 index 0000000..d68cfac --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c1/b0f50722774d001117ad98d4e911bb97 @@ -0,0 +1,251 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/a0e545d9384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c2/a0e545d9384d0011135ca7e1c9885acd deleted file mode 100644 index 0e74232..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/a0e545d9384d0011135ca7e1c9885acd +++ /dev/null @@ -1,124 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c3/50ce1dbca94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c3/50ce1dbca94c0011135ca7e1c9885acd deleted file mode 100644 index ac046d0..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c3/50ce1dbca94c0011135ca7e1c9885acd +++ /dev/null @@ -1,14 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c3/603cb0c2784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c3/603cb0c2784d001117ad98d4e911bb97 new file mode 100644 index 0000000..23a5241 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c3/603cb0c2784d001117ad98d4e911bb97 @@ -0,0 +1,271 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80a71e2afe4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80a71e2afe4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..d3b1797 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80a71e2afe4d00111282df97d7c4d0e2 @@ -0,0 +1,429 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = nextNode; + newNode.next = prevNode; + prevNode.next = newNode; + lastReturned = null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80b938f9764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80b938f9764d001117ad98d4e911bb97 new file mode 100644 index 0000000..67f97e3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80b938f9764d001117ad98d4e911bb97 @@ -0,0 +1,246 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + } + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c4/9051f9251e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c4/9051f9251e4d0011135ca7e1c9885acd deleted file mode 100644 index ea2f709..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c4/9051f9251e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,12 +0,0 @@ -package list.mylinkedlist; - -implements java.array:list; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c5/103f63c3804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c5/103f63c3804d001117ad98d4e911bb97 new file mode 100644 index 0000000..9895fae --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c5/103f63c3804d001117ad98d4e911bb97 @@ -0,0 +1,356 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if () + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c6/00fab5c27e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c6/00fab5c27e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..b85bf30 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c6/00fab5c27e4d001117ad98d4e911bb97 @@ -0,0 +1,330 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c8/90af0ff8864d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c8/90af0ff8864d001117ad98d4e911bb97 new file mode 100644 index 0000000..63b4218 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c8/90af0ff8864d001117ad98d4e911bb97 @@ -0,0 +1,382 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + size--; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c8/c098b1e7594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c8/c098b1e7594d001117ad98d4e911bb97 new file mode 100644 index 0000000..4bb7007 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c8/c098b1e7594d001117ad98d4e911bb97 @@ -0,0 +1,214 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c9/0046b2b6384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/c9/0046b2b6384d0011135ca7e1c9885acd deleted file mode 100644 index 681e580..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c9/0046b2b6384d0011135ca7e1c9885acd +++ /dev/null @@ -1,121 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c9/f0440658594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/c9/f0440658594d001117ad98d4e911bb97 new file mode 100644 index 0000000..765c761 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c9/f0440658594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o il secondo + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/50f3ed82794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/50f3ed82794d001117ad98d4e911bb97 new file mode 100644 index 0000000..c034fcf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/50f3ed82794d001117ad98d4e911bb97 @@ -0,0 +1,277 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/60fbbc12304d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/60fbbc12304d0011135ca7e1c9885acd deleted file mode 100644 index c3bfb72..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/60fbbc12304d0011135ca7e1c9885acd +++ /dev/null @@ -1,59 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - - } else { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/c08488a2594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/c08488a2594d001117ad98d4e911bb97 new file mode 100644 index 0000000..e68e20c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/c08488a2594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.) + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/d08127f97e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/d08127f97e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..3c48e4b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/d08127f97e4d001117ad98d4e911bb97 @@ -0,0 +1,335 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cb/e02a8003364d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/cb/e02a8003364d0011135ca7e1c9885acd deleted file mode 100644 index e7fb7d6..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cb/e02a8003364d0011135ca7e1c9885acd +++ /dev/null @@ -1,92 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cb/e05b733c334d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/cb/e05b733c334d0011135ca7e1c9885acd deleted file mode 100644 index 0cc777f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cb/e05b733c334d0011135ca7e1c9885acd +++ /dev/null @@ -1,76 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - head.next = null; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/70f59fc0354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/cc/70f59fc0354d0011135ca7e1c9885acd deleted file mode 100644 index 32e1658..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/70f59fc0354d0011135ca7e1c9885acd +++ /dev/null @@ -1,90 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) return new SuchElementException(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/f01161f7374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/cc/f01161f7374d0011135ca7e1c9885acd deleted file mode 100644 index ad554cb..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/f01161f7374d0011135ca7e1c9885acd +++ /dev/null @@ -1,114 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/20b02cd2814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/20b02cd2814d001117ad98d4e911bb97 new file mode 100644 index 0000000..6217b93 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/20b02cd2814d001117ad98d4e911bb97 @@ -0,0 +1,373 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/f08de8e1764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/f08de8e1764d001117ad98d4e911bb97 new file mode 100644 index 0000000..65f3786 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/f08de8e1764d001117ad98d4e911bb97 @@ -0,0 +1,241 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ce/00b59c4a374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ce/00b59c4a374d0011135ca7e1c9885acd deleted file mode 100644 index 045e11d..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ce/00b59c4a374d0011135ca7e1c9885acd +++ /dev/null @@ -1,107 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ce/7014cfdd7e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ce/7014cfdd7e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..133b4e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ce/7014cfdd7e4d001117ad98d4e911bb97 @@ -0,0 +1,334 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + nextNode = + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a020f2c4794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a020f2c4794d001117ad98d4e911bb97 new file mode 100644 index 0000000..57fa919 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a020f2c4794d001117ad98d4e911bb97 @@ -0,0 +1,282 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ce/c0ed5a49594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ce/c0ed5a49594d001117ad98d4e911bb97 new file mode 100644 index 0000000..080a302 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ce/c0ed5a49594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cf/301dffd87b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/cf/301dffd87b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..45d0068 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/cf/301dffd87b4d001117ad98d4e911bb97 @@ -0,0 +1,293 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 1; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cf/90ba5a017d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/cf/90ba5a017d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..264c0cb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/cf/90ba5a017d4d001117ad98d4e911bb97 @@ -0,0 +1,307 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + public boolean hasNext() { + return nextNode != null; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cf/a01fd7d8774d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/cf/a01fd7d8774d001117ad98d4e911bb97 new file mode 100644 index 0000000..1b661ee --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/cf/a01fd7d8774d001117ad98d4e911bb97 @@ -0,0 +1,255 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d/30fd20defb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/d/30fd20defb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..4a9a76b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d/30fd20defb4d00111282df97d7c4d0e2 @@ -0,0 +1,406 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se la lista è vuota + if (size == 0) { + tail = head = new Node(data, null, null); + size++; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d/606e191d7e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d/606e191d7e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..effea1d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d/606e191d7e4d001117ad98d4e911bb97 @@ -0,0 +1,322 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + nextNode = nextNode.next; + prevNode = nextNode.prev; + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d0/a0deb2a4344d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/d0/a0deb2a4344d0011135ca7e1c9885acd deleted file mode 100644 index 742c120..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d0/a0deb2a4344d0011135ca7e1c9885acd +++ /dev/null @@ -1,80 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - head.next.prev = null; - - head = head.next; - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d1/401839a5794d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d1/401839a5794d001117ad98d4e911bb97 new file mode 100644 index 0000000..43542ea --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d1/401839a5794d001117ad98d4e911bb97 @@ -0,0 +1,281 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d1/60cbf7405b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d1/60cbf7405b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..f899b32 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d1/60cbf7405b4d001117ad98d4e911bb97 @@ -0,0 +1,202 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + + } + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/00c04c0a3a4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/d2/00c04c0a3a4d0011135ca7e1c9885acd deleted file mode 100644 index ad40349..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/00c04c0a3a4d0011135ca7e1c9885acd +++ /dev/null @@ -1,137 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - if (index == 0) { - addFirst(item); - return; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/40b810ea764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d2/40b810ea764d001117ad98d4e911bb97 new file mode 100644 index 0000000..7d3ad85 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d2/40b810ea764d001117ad98d4e911bb97 @@ -0,0 +1,243 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/5021b4c4394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/d2/5021b4c4394d0011135ca7e1c9885acd deleted file mode 100644 index 267ced7..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/5021b4c4394d0011135ca7e1c9885acd +++ /dev/null @@ -1,134 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - if (index == 0) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d3/1086319c5b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d3/1086319c5b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..8615b2e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d3/1086319c5b4d001117ad98d4e911bb97 @@ -0,0 +1,212 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d3/e0040337ff4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/d3/e0040337ff4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..65d3ed4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d3/e0040337ff4d00111282df97d7c4d0e2 @@ -0,0 +1,438 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + return new MyLinkedListIterator(); + } + + public ListIterator listIterator() { + return new MyLinkedListIterator(); + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + @Override + public void set(E data) { + if (lastReturned == null) throw new NoSuchElementException(); + if (data == null) throw new NullPointerException(); + lastReturned.data = data; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d4/002684402f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/d4/002684402f4d0011135ca7e1c9885acd deleted file mode 100644 index 82a59cf..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d4/002684402f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,36 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d4/20fc4e7bfb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/d4/20fc4e7bfb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..787bec6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d4/20fc4e7bfb4d00111282df97d7c4d0e2 @@ -0,0 +1,403 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se la lista è vuota + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d5/00259d007f4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/00259d007f4d001117ad98d4e911bb97 new file mode 100644 index 0000000..f9d83b9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/00259d007f4d001117ad98d4e911bb97 @@ -0,0 +1,338 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d5/404e44ab324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/404e44ab324d0011135ca7e1c9885acd deleted file mode 100644 index 2b3dc54..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d5/404e44ab324d0011135ca7e1c9885acd +++ /dev/null @@ -1,72 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - if (size == 1) { - E tmp = head.data; - head = tail = null; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c030968e864d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c030968e864d001117ad98d4e911bb97 new file mode 100644 index 0000000..cf731b2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c030968e864d001117ad98d4e911bb97 @@ -0,0 +1,377 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c04b8a237e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c04b8a237e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..820e204 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c04b8a237e4d001117ad98d4e911bb97 @@ -0,0 +1,323 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + nextNode = nextNode.next; + prevNode = nextNode.prev; + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c09ebc84fb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c09ebc84fb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..b6c6019 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d5/c09ebc84fb4d00111282df97d7c4d0e2 @@ -0,0 +1,405 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se la lista è vuota + if (size == 0) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/10c828e95c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d7/10c828e95c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..54c7184 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d7/10c828e95c4d001117ad98d4e911bb97 @@ -0,0 +1,221 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/30fc1da4354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/d7/30fc1da4354d0011135ca7e1c9885acd deleted file mode 100644 index e37e599..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/30fc1da4354d0011135ca7e1c9885acd +++ /dev/null @@ -1,86 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d8/80ed6fd52f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/d8/80ed6fd52f4d0011135ca7e1c9885acd deleted file mode 100644 index 06ea5d1..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d8/80ed6fd52f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,54 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d9/30fb53fd834d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d9/30fb53fd834d001117ad98d4e911bb97 new file mode 100644 index 0000000..dfac56b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d9/30fb53fd834d001117ad98d4e911bb97 @@ -0,0 +1,374 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d9/9074038c5d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/d9/9074038c5d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..e9d80c9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d9/9074038c5d4d001117ad98d4e911bb97 @@ -0,0 +1,225 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d9/e0b72a69a84c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/d9/e0b72a69a84c0011135ca7e1c9885acd deleted file mode 100644 index 21e3c23..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d9/e0b72a69a84c0011135ca7e1c9885acd +++ /dev/null @@ -1,7 +0,0 @@ -package jcf_map.exercise; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - */ -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/da/10811de0a94c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/da/10811de0a94c0011135ca7e1c9885acd deleted file mode 100644 index f08fff1..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/da/10811de0a94c0011135ca7e1c9885acd +++ /dev/null @@ -1,18 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/da/908b1c2eaa4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/da/908b1c2eaa4c0011135ca7e1c9885acd deleted file mode 100644 index 442fcab..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/da/908b1c2eaa4c0011135ca7e1c9885acd +++ /dev/null @@ -1,24 +0,0 @@ -package jcf_map.exercise; - -import java.util.Map; - -import binary_tree.BinaryNode; - -public class BinaryTreeMap { - /* - * Esercizio 1 - Esame del secondo parziale 8/1/2019 - * Scrivere un metodo generico statico ContaDuplicati che conta il numero - * di oggetti duplicati (non univoci) contenuti in un albero binario. - * Il risultato è il conteggio totale degli elementi che risultano duplicati - * (non il numero totale di occorrenze, ma il numero di oggetti distinti che - * hanno almeno un duplicato) - */ - public static Map ContaDuplicati(BinaryNode node) { - - } - - protected static Map ContaDuplicati(BinaryNode node, HashMap mappa) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/da/90fd1cfafb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/da/90fd1cfafb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..63f7568 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/da/90fd1cfafb4d00111282df97d7c4d0e2 @@ -0,0 +1,408 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = new Node(data, null, null); + size++; + prevNode = + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/da/c017ad9e374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/da/c017ad9e374d0011135ca7e1c9885acd deleted file mode 100644 index 3fb13dd..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/da/c017ad9e374d0011135ca7e1c9885acd +++ /dev/null @@ -1,114 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(); - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/db/a096ef26594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/db/a096ef26594d001117ad98d4e911bb97 new file mode 100644 index 0000000..27eaf3d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/db/a096ef26594d001117ad98d4e911bb97 @@ -0,0 +1,203 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + + } + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/dc/50fce311374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/dc/50fce311374d0011135ca7e1c9885acd deleted file mode 100644 index bf9af33..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/dc/50fce311374d0011135ca7e1c9885acd +++ /dev/null @@ -1,101 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/de/90bc596a594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/de/90bc596a594d001117ad98d4e911bb97 new file mode 100644 index 0000000..9fc47b3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/de/90bc596a594d001117ad98d4e911bb97 @@ -0,0 +1,210 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/de/d0d81ce2804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/de/d0d81ce2804d001117ad98d4e911bb97 new file mode 100644 index 0000000..1b6a985 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/de/d0d81ce2804d001117ad98d4e911bb97 @@ -0,0 +1,364 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/de/e0f7a0da2f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/de/e0f7a0da2f4d0011135ca7e1c9885acd deleted file mode 100644 index 778b6be..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/de/e0f7a0da2f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,55 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if () - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/df/0040967f7d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/df/0040967f7d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..137bd8e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/df/0040967f7d4d001117ad98d4e911bb97 @@ -0,0 +1,315 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/df/20c27ace754d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/df/20c27ace754d001117ad98d4e911bb97 new file mode 100644 index 0000000..f2100ed --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/df/20c27ace754d001117ad98d4e911bb97 @@ -0,0 +1,228 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null) return false; + for () + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/df/70f187997d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/df/70f187997d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..7034f98 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/df/70f187997d4d001117ad98d4e911bb97 @@ -0,0 +1,318 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/df/80ab8c475b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/df/80ab8c475b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..07cc66e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/df/80ab8c475b4d001117ad98d4e911bb97 @@ -0,0 +1,202 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + } + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e/507ab028764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e/507ab028764d001117ad98d4e911bb97 new file mode 100644 index 0000000..b912b91 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e/507ab028764d001117ad98d4e911bb97 @@ -0,0 +1,231 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e/f01b0ddc384d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/e/f01b0ddc384d0011135ca7e1c9885acd deleted file mode 100644 index 5c70255..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e/f01b0ddc384d0011135ca7e1c9885acd +++ /dev/null @@ -1,126 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e/f0675cc2344d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/e/f0675cc2344d0011135ca7e1c9885acd deleted file mode 100644 index d0d99b0..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e/f0675cc2344d0011135ca7e1c9885acd +++ /dev/null @@ -1,81 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - head.next.prev = null; - - head = head.next; - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e0/808f90b0374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/e0/808f90b0374d0011135ca7e1c9885acd deleted file mode 100644 index efd0825..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e0/808f90b0374d0011135ca7e1c9885acd +++ /dev/null @@ -1,113 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(); - } - size++; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e0/b02052d1574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e0/b02052d1574d001117ad98d4e911bb97 new file mode 100644 index 0000000..3fb0490 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e0/b02052d1574d001117ad98d4e911bb97 @@ -0,0 +1,193 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if () { + + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/302c0c891e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/302c0c891e4d0011135ca7e1c9885acd deleted file mode 100644 index 4693970..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/302c0c891e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,27 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Data - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/3045076b5a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/3045076b5a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..0c2d9e6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/3045076b5a4d001117ad98d4e911bb97 @@ -0,0 +1,220 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + currentNode = currentNode.next; + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + size--; + return true; + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e02939a4784d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e02939a4784d001117ad98d4e911bb97 new file mode 100644 index 0000000..ed066f9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e02939a4784d001117ad98d4e911bb97 @@ -0,0 +1,268 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e2/603ac3da864d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e2/603ac3da864d001117ad98d4e911bb97 new file mode 100644 index 0000000..b7f3fa2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e2/603ac3da864d001117ad98d4e911bb97 @@ -0,0 +1,380 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/609cff06304d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/e3/609cff06304d0011135ca7e1c9885acd deleted file mode 100644 index 65b5a6b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/609cff06304d0011135ca7e1c9885acd +++ /dev/null @@ -1,57 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/a0ea685f804d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e3/a0ea685f804d001117ad98d4e911bb97 new file mode 100644 index 0000000..8edf9bf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e3/a0ea685f804d001117ad98d4e911bb97 @@ -0,0 +1,350 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + @Override + public void remove() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e4/205450e8354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/e4/205450e8354d0011135ca7e1c9885acd deleted file mode 100644 index aecb996..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e4/205450e8354d0011135ca7e1c9885acd +++ /dev/null @@ -1,91 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e6/00af1de57b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e6/00af1de57b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..1179d82 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e6/00af1de57b4d001117ad98d4e911bb97 @@ -0,0 +1,294 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head.next; + prevNode = head; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/3013d1131f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/e7/3013d1131f4d0011135ca7e1c9885acd deleted file mode 100644 index 1ff4cbc..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/3013d1131f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,31 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e8/a049ab1c864d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e8/a049ab1c864d001117ad98d4e911bb97 new file mode 100644 index 0000000..e1964ec --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e8/a049ab1c864d001117ad98d4e911bb97 @@ -0,0 +1,374 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/00e6be175d4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/00e6be175d4d001117ad98d4e911bb97 new file mode 100644 index 0000000..6f56335 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/00e6be175d4d001117ad98d4e911bb97 @@ -0,0 +1,223 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/300b1d78fd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/300b1d78fd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..150af02 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/300b1d78fd4d00111282df97d7c4d0e2 @@ -0,0 +1,414 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/309be5ff864d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/309be5ff864d001117ad98d4e911bb97 new file mode 100644 index 0000000..8d47ba5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/309be5ff864d001117ad98d4e911bb97 @@ -0,0 +1,384 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + size--; + nextNode = nNode; + prevNode = pNode; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/a02e45213a4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/a02e45213a4d0011135ca7e1c9885acd deleted file mode 100644 index d6cfed4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/a02e45213a4d0011135ca7e1c9885acd +++ /dev/null @@ -1,140 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - if (index < 0 || index > size) throw new IndexOutOfBoundsException(); - - if (index == 0) { - addFirst(item); - return; - } - - if () - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/e07c0cdc7e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/e07c0cdc7e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..7f26190 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/e07c0cdc7e4d001117ad98d4e911bb97 @@ -0,0 +1,333 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + prevNode = prevNode.prev; + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/f096c870814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/f096c870814d001117ad98d4e911bb97 new file mode 100644 index 0000000..be1b491 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/f096c870814d001117ad98d4e911bb97 @@ -0,0 +1,368 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/20c46eea314d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/20c46eea314d0011135ca7e1c9885acd deleted file mode 100644 index 52d298e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/20c46eea314d0011135ca7e1c9885acd +++ /dev/null @@ -1,62 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/30d88b7f5b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/30d88b7f5b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..4dc8f35 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/30d88b7f5b4d001117ad98d4e911bb97 @@ -0,0 +1,203 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + + } + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/507c0e3f374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/507c0e3f374d0011135ca7e1c9885acd deleted file mode 100644 index 315a97a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/507c0e3f374d0011135ca7e1c9885acd +++ /dev/null @@ -1,103 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/70e27a56374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/70e27a56374d0011135ca7e1c9885acd deleted file mode 100644 index dcda986..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/70e27a56374d0011135ca7e1c9885acd +++ /dev/null @@ -1,107 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/a07c186e354d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/a07c186e354d0011135ca7e1c9885acd deleted file mode 100644 index b07c0ca..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/a07c186e354d0011135ca7e1c9885acd +++ /dev/null @@ -1,85 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ec/009a9879814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ec/009a9879814d001117ad98d4e911bb97 new file mode 100644 index 0000000..d4b8f89 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ec/009a9879814d001117ad98d4e911bb97 @@ -0,0 +1,368 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ed/00c5c70e334d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ed/00c5c70e334d0011135ca7e1c9885acd deleted file mode 100644 index 01a4da3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ed/00c5c70e334d0011135ca7e1c9885acd +++ /dev/null @@ -1,76 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - - } - size--; - return tmp; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ee/204e902f1e4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ee/204e902f1e4d0011135ca7e1c9885acd deleted file mode 100644 index 239f70f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ee/204e902f1e4d0011135ca7e1c9885acd +++ /dev/null @@ -1,12 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ee/4089760ffc4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/ee/4089760ffc4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..a8e9926 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ee/4089760ffc4d00111282df97d7c4d0e2 @@ -0,0 +1,409 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ef/503adbbcfb4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/ef/503adbbcfb4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..b0bfc87 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ef/503adbbcfb4d00111282df97d7c4d0e2 @@ -0,0 +1,406 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + // Se la lista è vuota + if (size == 0) { + tail = head = new Node(data, null, null); + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ef/903f2035594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/ef/903f2035594d001117ad98d4e911bb97 new file mode 100644 index 0000000..54174a5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ef/903f2035594d001117ad98d4e911bb97 @@ -0,0 +1,205 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f/2005b9768e4c0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/f/2005b9768e4c0011135ca7e1c9885acd deleted file mode 100644 index 94783fb..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f/2005b9768e4c0011135ca7e1c9885acd +++ /dev/null @@ -1,5 +0,0 @@ -package jcf_map.exercise; - -public class Dispari { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f1/d02671bdfd4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/f1/d02671bdfd4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..d4ba284 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f1/d02671bdfd4d00111282df97d7c4d0e2 @@ -0,0 +1,419 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f2/90903d197a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/90903d197a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..2d95213 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/90903d197a4d001117ad98d4e911bb97 @@ -0,0 +1,285 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f2/a0e404d4574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/a0e404d4574d001117ad98d4e911bb97 new file mode 100644 index 0000000..463d7d3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/a0e404d4574d001117ad98d4e911bb97 @@ -0,0 +1,191 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return null; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f2/b08e7deb764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/b08e7deb764d001117ad98d4e911bb97 new file mode 100644 index 0000000..5034519 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/b08e7deb764d001117ad98d4e911bb97 @@ -0,0 +1,243 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i] = currentNode; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f2/e087f723ff4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/e087f723ff4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..fd8bddb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/e087f723ff4d00111282df97d7c4d0e2 @@ -0,0 +1,438 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + @Override + public void set(E data) { + if (lastReturned == null) throw new NoSuchElementException(); + if (data == null) throw new NullPointerException(); + lastReturned.data = data; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/107ecf8a814d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/107ecf8a814d001117ad98d4e911bb97 new file mode 100644 index 0000000..7edc721 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/107ecf8a814d001117ad98d4e911bb97 @@ -0,0 +1,369 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + + return; + } + // Se è un elemento generico + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/c0601a52324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/c0601a52324d0011135ca7e1c9885acd deleted file mode 100644 index 050c951..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/c0601a52324d0011135ca7e1c9885acd +++ /dev/null @@ -1,67 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f4/20ff08f2594d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f4/20ff08f2594d001117ad98d4e911bb97 new file mode 100644 index 0000000..2445383 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f4/20ff08f2594d001117ad98d4e911bb97 @@ -0,0 +1,215 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + } + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/50cfaf89574d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/50cfaf89574d001117ad98d4e911bb97 new file mode 100644 index 0000000..c5b826d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/50cfaf89574d001117ad98d4e911bb97 @@ -0,0 +1,191 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f6/30d4ee8d394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/f6/30d4ee8d394d0011135ca7e1c9885acd deleted file mode 100644 index d52bcae..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f6/30d4ee8d394d0011135ca7e1c9885acd +++ /dev/null @@ -1,133 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add(int index, E item) { - if (item == null) throw new NullPointerException(); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f6/8088a1e67e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f6/8088a1e67e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..7bf846e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f6/8088a1e67e4d001117ad98d4e911bb97 @@ -0,0 +1,334 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f6/a0dcbb267e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f6/a0dcbb267e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..924f90d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f6/a0dcbb267e4d001117ad98d4e911bb97 @@ -0,0 +1,323 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f8/306865ce2f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/f8/306865ce2f4d0011135ca7e1c9885acd deleted file mode 100644 index bf0e0ef..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f8/306865ce2f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,54 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if () - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f8/609ab05b7c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f8/609ab05b7c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..1acea55 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f8/609ab05b7c4d001117ad98d4e911bb97 @@ -0,0 +1,300 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + Node currentNode = head; + int pos = 0; + while (i < index) { + + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f9/50697e5a374d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/f9/50697e5a374d0011135ca7e1c9885acd deleted file mode 100644 index 93a8e62..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f9/50697e5a374d0011135ca7e1c9885acd +++ /dev/null @@ -1,108 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f9/b0f2ebff584d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f9/b0f2ebff584d001117ad98d4e911bb97 new file mode 100644 index 0000000..8871e2f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f9/b0f2ebff584d001117ad98d4e911bb97 @@ -0,0 +1,201 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.) + // Iterazione per la ricerca dell'oggetto + Node currentNode = head; + + while (currentNode.next != null) { + currentNode = currentNode.next; + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f9/f0cf52385b4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/f9/f0cf52385b4d001117ad98d4e911bb97 new file mode 100644 index 0000000..ae4fcdf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f9/f0cf52385b4d001117ad98d4e911bb97 @@ -0,0 +1,200 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + + + } + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fa/802595e85a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/fa/802595e85a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..21f2062 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/fa/802595e85a4d001117ad98d4e911bb97 @@ -0,0 +1,221 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode; + // Caso in cui sia il primo + currentNode = head; + if (currentNode.data.equals(object)) { + removeFirst(); + return true; + } + // Caso in cui sia l'ultimo + currentNode = tail; + if (currentNode.data.equals(object)) { + removeLast(); + return true; + } + // Caso in cui non sia il primo o l'ultimo, sia quindi tra il primo e il secondo (non per forza) + currentNode = head; + while (currentNode.next != null) { + currentNode = currentNode.next; + if (currentNode.data.equals(object)) { + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + size--; + return true; + } + } + return false; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fa/c0e9e8207a4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/fa/c0e9e8207a4d001117ad98d4e911bb97 new file mode 100644 index 0000000..8e911b5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/fa/c0e9e8207a4d001117ad98d4e911bb97 @@ -0,0 +1,285 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + } + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fb/0056d117304d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/fb/0056d117304d0011135ca7e1c9885acd deleted file mode 100644 index d81522c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/fb/0056d117304d0011135ca7e1c9885acd +++ /dev/null @@ -1,59 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = - } else { - - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fb/00e45c525e4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/fb/00e45c525e4d001117ad98d4e911bb97 new file mode 100644 index 0000000..f70801c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/fb/00e45c525e4d001117ad98d4e911bb97 @@ -0,0 +1,235 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean removeRec(E object) { + if ((object == null) || (head == null)) return false; + if (head.data.equals(object)) { + removeFirst(); + return true; + } else return removeRec(); + } + + private boolean removeRec() { + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fc/70397e4f2f4d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/fc/70397e4f2f4d0011135ca7e1c9885acd deleted file mode 100644 index 6ea07a3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/fc/70397e4f2f4d0011135ca7e1c9885acd +++ /dev/null @@ -1,40 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fc/b08ee6f47c4d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/fc/b08ee6f47c4d001117ad98d4e911bb97 new file mode 100644 index 0000000..e0eceeb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/fc/b08ee6f47c4d001117ad98d4e911bb97 @@ -0,0 +1,307 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + public boolean hasNext() { + + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fd/b09e96bb324d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/fd/b09e96bb324d0011135ca7e1c9885acd deleted file mode 100644 index 09a40d3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/fd/b09e96bb324d0011135ca7e1c9885acd +++ /dev/null @@ -1,74 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - if (size == 0) { - head = tail = new Node(item, null, null); - } else { - Node newNode = new Node(item, null, null); - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp; - if (size == 1) { - E tmp = head.data; - head = tail = null; - return tmp; - } - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fe/c09ab21d764d001117ad98d4e911bb97 b/.metadata/.plugins/org.eclipse.core.resources/.history/fe/c09ab21d764d001117ad98d4e911bb97 new file mode 100644 index 0000000..0cc84d9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/fe/c09ab21d764d001117ad98d4e911bb97 @@ -0,0 +1,228 @@ +package list.mylinkedlist; + +import java.util.List; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/a0c1cb17394d0011135ca7e1c9885acd b/.metadata/.plugins/org.eclipse.core.resources/.history/ff/a0c1cb17394d0011135ca7e1c9885acd deleted file mode 100644 index a930e41..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/a0c1cb17394d0011135ca7e1c9885acd +++ /dev/null @@ -1,132 +0,0 @@ -package list.mylinkedlist; - -import java.util.List; -import java.util.NoSuchElementException; - -public class MyLinkedList implements List { - - /* - * Classe Nodo - */ - private static class Node { - - // Dati del nodo - private E data; - - // Riferimenti elemento precedente e successivo - private Node prev; - private Node next; - - // Costruttore - public Node(E data, Node prev, Node next) { - this.data = data; - this.prev = prev; - this.next = next; - } - - } - - private Node head = null; - private Node tail = null; - private int size = 0; - - // Costruttore - public MyLinkedList() {} - - // Metodi - - public boolean isEmpty() { - return size == 0; - } - - public int size() { - return size; - } - - public E getFirst() { - if (head == null) throw new NullPointerException(); - return head.data; - } - - public void addFirst(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - head.prev = newNode; - newNode.next = head; - head = newNode; - } - size++; - } - - public E removeFirst() { - if (head == null) throw new NoSuchElementException(); - E tmp = head.data; - if (size == 1) { - head = tail = null; - } else { - Node firstPlace = head; - Node secondPlace = head.next; - - head = secondPlace; - secondPlace.prev = null; - firstPlace.next = null; - } - size--; - return tmp; - } - - public E getLast() { - if (tail == null) throw new NullPointerException(); - return tail.data; - } - - public E removeLast() { - if (tail == null) throw new NoSuchElementException(); - E tmp = tail.data; - if (size == 1) { - head = tail = null; - } else { - Node lastNode = tail; - Node penultimateNode = tail.prev; - - tail = penultimateNode; - penultimateNode.next = null; - lastNode.prev = null; - } - size--; - return tmp; - } - - public void addLast(E item) { - if (item == null) throw new NullPointerException(); - Node newNode = new Node(item, null, null); - if (size == 0) { - head = tail = newNode; - } else { - Node oldLastNode = tail; - oldLastNode.next = newNode; - newNode.prev = oldLastNode; - tail = newNode; - } - size++; - } - - public void clear() { - head = tail = null; - size = 0; - } - - public boolean add(E item) { - if (item == null) throw new NoSuchElementException(); - addLast(item); - return true; - } - - public void add() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/f091830aff4d00111282df97d7c4d0e2 b/.metadata/.plugins/org.eclipse.core.resources/.history/ff/f091830aff4d00111282df97d7c4d0e2 new file mode 100644 index 0000000..c159962 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ff/f091830aff4d00111282df97d7c4d0e2 @@ -0,0 +1,437 @@ +package list.mylinkedlist; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +public class MyLinkedList implements List { + + /* + * Classe Nodo + */ + private static class Node { + + // Dati del nodo + private E data; + + // Riferimenti elemento precedente e successivo + private Node prev; + private Node next; + + // Costruttore + public Node(E data, Node prev, Node next) { + this.data = data; + this.prev = prev; + this.next = next; + } + + } + + private Node head = null; + private Node tail = null; + private int size = 0; + + // Costruttore + public MyLinkedList() {} + + // Metodi + + public boolean isEmpty() { + return size == 0; + } + + public int size() { + return size; + } + + public E getFirst() { + if (head == null) throw new NullPointerException(); + return head.data; + } + + public void addFirst(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + head.prev = newNode; + newNode.next = head; + head = newNode; + } + size++; + } + + public E removeFirst() { + if (head == null) throw new NoSuchElementException(); + E tmp = head.data; + if (size == 1) { + head = tail = null; + } else { + Node firstPlace = head; + Node secondPlace = head.next; + + head = secondPlace; + secondPlace.prev = null; + firstPlace.next = null; + } + size--; + return tmp; + } + + public E getLast() { + if (tail == null) throw new NullPointerException(); + return tail.data; + } + + public E removeLast() { + if (tail == null) throw new NoSuchElementException(); + E tmp = tail.data; + if (size == 1) { + head = tail = null; + } else { + Node lastNode = tail; + Node penultimateNode = tail.prev; + + tail = penultimateNode; + penultimateNode.next = null; + lastNode.prev = null; + } + size--; + return tmp; + } + + public void addLast(E item) { + if (item == null) throw new NullPointerException(); + Node newNode = new Node(item, null, null); + if (size == 0) { + head = tail = newNode; + } else { + Node oldLastNode = tail; + oldLastNode.next = newNode; + newNode.prev = oldLastNode; + tail = newNode; + } + size++; + } + + public void clear() { + head = tail = null; + size = 0; + } + + public boolean add(E item) { + if (item == null) throw new NoSuchElementException(); + addLast(item); + return true; + } + + public void add(int index, E item) { + if (item == null) throw new NullPointerException(); + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); + // Se l'inserimento è richiesto nella prima posizione + if (index == 0) { + addFirst(item); + return; + } + // Se l'inserimento è richiesto nell'ultima posizione + if (index == size) { + addLast(item); + return; + } + // Se l'inserimento è richiesto nel generico posto i + Node newNode = new Node(item, null, null); + + Node prevNode = head; + for (int i = 0; i < index - 1; i++) { + prevNode = prevNode.next; + } + + Node nextNode = prevNode.next; + + prevNode.next = newNode; + newNode.prev = prevNode; + newNode.next = nextNode; + nextNode.prev = newNode; + + size++; + } + + public E get(int index) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + return currentNode.data; + } + + public E set(int index, E item) { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + Node currentNode = head; + for (int i = 0; i < index; i++) { + currentNode = currentNode.next; + } + E oldData = currentNode.data; + currentNode.data = item; + return oldData; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + + } + + public ListIterator listIterator() { + + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + @Override + public void set(E data) { + if (lastReturned == null) throw new NoSuchElementException(); + if (data == null) throw new NullPointerException(;) + } + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.indexes/e4/96/d8/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.indexes/e4/96/d8/history.index index 5427232..92831a1 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.indexes/e4/96/d8/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.indexes/e4/96/d8/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.indexes/e4/9e/1d/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.indexes/e4/9e/1d/history.index index df90cf7..24c44b3 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.indexes/e4/9e/1d/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.indexes/e4/9e/1d/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.markers b/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.markers index fac457a..ec7fd6a 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.markers and b/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.markers differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.markers.snap index c68038d..f5044ff 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.markers.snap and b/.metadata/.plugins/org.eclipse.core.resources/.projects/asdl/.markers.snap differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap index 0ef1fa6..08e6b18 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap and b/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree deleted file mode 100644 index 40d82a8..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/3.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/3.tree new file mode 100644 index 0000000..8d27d6e Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/3.tree differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources index 66adea3..6dffc96 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/2.snap b/.metadata/.plugins/org.eclipse.core.resources/2.snap deleted file mode 100644 index f7a53ad..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/2.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/3.snap b/.metadata/.plugins/org.eclipse.core.resources/3.snap new file mode 100644 index 0000000..14d24e9 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/3.snap differ diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs index ff92bb2..a815d4c 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -9,7 +9,9 @@ content_assist_parameters_background,defaultValueBeforeOverriddenFromCSS=255,255 content_assist_parameters_foreground=238,238,238 content_assist_parameters_foreground,defaultValueBeforeOverriddenFromCSS=0,0,0 content_assist_proposals_background=255,255,255 +content_assist_proposals_background,defaultValueBeforeOverriddenFromCSS=255,255,255 content_assist_proposals_foreground=0,0,0 +content_assist_proposals_foreground,defaultValueBeforeOverriddenFromCSS=0,0,0 eclipse.preferences.version=1 java_bracket=249,250,244 java_bracket,defaultValueBeforeOverriddenFromCSS=0,0,0 diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi index b1fd3e5..0448152 100644 --- a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -1,8 +1,8 @@ - - + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration - + @@ -11,9 +11,9 @@ topLevel shellMaximized - - - + + + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation persp.actionSet:org.eclipse.ui.cheatsheets.actionSet @@ -80,2481 +80,2473 @@ persp.editorOnboardingCommand:Show Key Assist$$$Ctrl+Shift+L persp.editorOnboardingCommand:New$$$Ctrl+N persp.editorOnboardingCommand:Open Type$$$Ctrl+Shift+T - - - + + + org.eclipse.e4.primaryNavigationStack - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:General - + View categoryTag:Java - - + + View categoryTag:Git - - - - + + + + org.eclipse.e4.secondaryNavigationStack Minimized - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Mylyn - + View categoryTag:Java - + View categoryTag:Ant - + org.eclipse.e4.secondaryDataStack Oomph - + Java + View categoryTag:General - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Terminal - + View categoryTag:General - + View categoryTag:Oomph NoRestore - + View categoryTag:Oomph NoRestore + + View + categoryTag:Java + - - + + View categoryTag:Help - + View categoryTag:General - + View categoryTag:Help - + View categoryTag:Help - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:Help - - + + EditorStack org.eclipse.e4.primaryDataStack active - noFocus - - - Editor - removeOnHide - org.eclipse.jdt.ui.CompilationUnitEditor - - - + + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor active - - - Editor - removeOnHide - org.eclipse.jdt.ui.CompilationUnitEditor - - - - Editor - removeOnHide - org.eclipse.jdt.ui.CompilationUnitEditor - - - - Editor - removeOnHide - org.eclipse.jdt.ui.CompilationUnitEditor - - + View categoryTag:Java - + ViewMenu menuContribution:menu - + - + View categoryTag:Java - + View categoryTag:General - + - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:General - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Mylyn - + View categoryTag:Terminal - + View categoryTag:Java - + View categoryTag:Git - + View categoryTag:Java - + View categoryTag:Ant - + View categoryTag:Oomph NoRestore - + ViewMenu menuContribution:menu - + - + View categoryTag:Oomph NoRestore - + ViewMenu menuContribution:menu - + - - + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + toolbarSeparator - + - + Draggable - + - + toolbarSeparator - + - + Draggable - - + + - + toolbarSeparator - + - + Draggable - + Draggable - + Draggable - + Draggable - + toolbarSeparator - + - + Draggable - + - + Draggable - + toolbarSeparator - + - + toolbarSeparator - + - + Draggable - + stretch SHOW_RESTORE_MENU - + Draggable HIDEABLE SHOW_RESTORE_MENU - - + + stretch - + Draggable - + Draggable - - + + TrimStack Draggable - + TrimStack Draggable - - + + TrimStack Draggable - + TrimStack Draggable - + TrimStack Draggable - - - - - - + + + + + + platform:cocoa - + platform:cocoa - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + platform:win32 - - - + + + - - - - - - - - - + + + + + + + + + platform:cocoa - - - - - - - - - - - - - - + + + + + + + + + + + + + + platform:cocoa - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - - - + + + + + - - + + - - - + + + - - - + + + - - - - - - - - - + + + + + + + + + - - + + - - + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - + + + + - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - + + platform:win32 - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - + + - - + + - - + + - - + + - - - + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - + + - - + + - - - - + + + + - - + + - - - - - - + + + + + + - - - - + + + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor removeOnHide - + View categoryTag:Ant - + View categoryTag:Gradle - + View categoryTag:Gradle - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Java - + View categoryTag:Git - + View categoryTag:Git - + View categoryTag:Git - + View categoryTag:Git NoRestore - + View categoryTag:Git - + View categoryTag:Help - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:Debug - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:Java Browsing - + View categoryTag:Java Browsing - + View categoryTag:Java Browsing - + View categoryTag:Java Browsing - + View categoryTag:Java - + View categoryTag:General - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:Language Servers - + View categoryTag:Language Servers - + View categoryTag:Language Servers - + View categoryTag:Maven - + View categoryTag:Maven - + View categoryTag:Maven - + View categoryTag:Mylyn - + View categoryTag:Mylyn - + View categoryTag:Mylyn - + View categoryTag:Mylyn - + View categoryTag:Mylyn - + View categoryTag:Mylyn - + View categoryTag:Oomph - + View categoryTag:Oomph NoRestore - + View categoryTag:Plug-in Development - + View categoryTag:General - + View categoryTag:Version Control (Team) - + View categoryTag:Version Control (Team) - + View categoryTag:Terminal - + View categoryTag:Help - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Help - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - - + + glue move_after:PerspectiveSpacer SHOW_RESTORE_MENU - + move_after:Spacer Glue HIDEABLE SHOW_RESTORE_MENU - + glue move_after:SearchField SHOW_RESTORE_MENU - - - - - + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - + + + - - - - - - - - + + + + + + + + - - - - - + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index index a4d58f6..0037c30 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index and b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/2876837992.index b/.metadata/.plugins/org.eclipse.jdt.core/2876837992.index index 6baba15..900aab8 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/2876837992.index and b/.metadata/.plugins/org.eclipse.jdt.core/2876837992.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml index 1ab2a78..678f1b1 100644 --- a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -1,5 +1,11 @@
+ + + + + +
@@ -37,4 +43,12 @@
+
+ + + + +
+
+
diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png index 3ac89df..6630b18 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png index a4446f4..469abaa 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/10.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/10.png deleted file mode 100644 index db1121a..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/10.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png index 6630b18..dfbdbb0 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png deleted file mode 100644 index f5c6e73..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png deleted file mode 100644 index 1e41e1f..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png deleted file mode 100644 index 469abaa..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/6.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/6.png deleted file mode 100644 index f6e5026..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/6.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/7.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/7.png deleted file mode 100644 index dfbdbb0..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/7.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/8.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/8.png deleted file mode 100644 index 4210c2a..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/8.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/9.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/9.png deleted file mode 100644 index 05b280b..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/9.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.m2e.logback/0.log b/.metadata/.plugins/org.eclipse.m2e.logback/0.log index f906d07..80a58e3 100644 --- a/.metadata/.plugins/org.eclipse.m2e.logback/0.log +++ b/.metadata/.plugins/org.eclipse.m2e.logback/0.log @@ -3,3 +3,5 @@ 2026-05-02 22:23:21,340 [Worker-2: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. 2026-05-09 20:34:37,650 [Worker-1: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. 2026-05-10 01:32:01,791 [Worker-5: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. +2026-05-10 18:30:16,902 [Worker-6: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. +2026-05-11 17:51:48,080 [Worker-5: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Crashpad/settings.dat b/.metadata/.plugins/org.eclipse.swt/EBWebView/Crashpad/settings.dat index 4083a1e..94d7aa7 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Crashpad/settings.dat and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Crashpad/settings.dat differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/BrowsingTopicsState b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/BrowsingTopicsState index 192cbf1..5063d4d 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/BrowsingTopicsState +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/BrowsingTopicsState @@ -8,5 +8,5 @@ "top_topics_and_observing_domains": [ ] } ], "hex_encoded_hmac_key": "3DA604280665A873D0EA6D316B3A72B9F419BDC719033123A3E96DBB0342BE2C", - "next_scheduled_calculation_time": "13423430092943205" + "next_scheduled_calculation_time": "13423430092943254" } diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_0 b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_0 index 0f2e114..62c7621 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_0 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_0 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_1 b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_1 index b7fbb0c..4d543f6 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_1 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_1 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_3 b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_3 index 4a76857..20fcc01 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_3 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/data_3 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/f_000004 b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/f_000006 similarity index 85% rename from .metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/f_000004 rename to .metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/f_000006 index 935f1d4..108edf9 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/f_000004 +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Cache/Cache_Data/f_000006 @@ -1 +1 @@ -[{"organization_id":656,"name":"IBM","member_since":"2002-02-21","renewal_date":"2027-01-01","description":{"long":"IBM and Eclipse\r\n
\r\nIBM is proud to be among the founders of the Eclipse project. Beginning in 2001, both IBM and Rational Software were founding members of the Eclipse consortium and the not for profit Eclipse Foundation. Rational Software was acquired by IBM in 2003, and today IBM Rational continues as a Strategic Member of the Eclipse Foundation.\r\n

\r\nEclipse continues to be core to dozens of IBM offerings from Rational, WebSphere, Lotus, Tivoli, and Information Management. IBM Rational software provides an Eclipse-based software development platform that improves the speed, quality, and predictability of software projects. This full life-cycle solution combines software engineering best practices, market-leading tools, and services.

\r\n\r\nThe Rational Software Delivery Platform\r\n
\r\nThe Rational Software Delivery Platform helps align all aspects of development and engineering operations with business needs. This highly collaborative environment supports IT as well as systems engineering efforts, and spans the entire project lifecycle with a complete, integrated set of products, services, and best practices.\r\n

\r\nA key component of the Rational portfolio is Jazz, a technology platform for collaborative software delivery. Uniquely attuned to global and distributed teams, the Jazz platform is designed to transform how people work together to build software -- making software delivery more collaborative, productive, and transparent.\r\n

\r\nThe IBM Rational Software Development Platform is the industry\\'s most complete, open, standards-based software development environment, and it enables our clients to more easily govern their software and systems development and delivery. Ninety-three of the Fortune Top 100 companies use Rational software.\r\n

\r\nAdditional information is available at ibm.com/rational"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/656-web.gif"},"website":"https://www.ibm.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"},{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"},{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":665,"name":"SAP SE","member_since":"2004-01-01","renewal_date":"2027-02-01","description":{"long":"SAP has a rich history of innovation and growth that has made us the recognized leader in providing collaborative business solutions for all types of industries in every major market. \\r\\n\\r\\nAs a market leader in enterprise application and digital transformation software, SAP helps companies of all sizes and industries run better. From back office to boardroom, warehouse to storefront, desktop to mobile devices, SAP empowers people and organizations to work together more efficiently by utilizing cloud, analytics, machine learning, Big Data, IoT and other insights more effectively to stay ahead of the competition. SAP applications and open cloud platform services enable more than 296,000 customers in 190 countries to operate profitably, adapt continuously, and grow sustainably.\\r\\n\\r\\nSAP has been a strategic member of the Eclipse Foundation since its inception."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/665-web.png"},"website":"https://www.sap.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Platinum Member","level":"WGPLM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":682,"name":"Ericsson AB","member_since":"2004-01-14","renewal_date":"2027-02-01","description":{"long":"At Ericsson, we strive to connect everyone, wherever they may be. Because by being connected, people can take part in the emerging global collaboration that is the Networked Society - a society in which every person and every industry is empowered to reach their full potential.\\r\\nOur services, software and infrastructure - especially in mobility, broadband and the cloud - are enabling the communications industry and other sectors to do better business, increase efficiency, improve their users\\' experience and capture new opportunities.\\r\\nBy enabling the Networked Society, we make a real difference to people\\'s lives, and the world we live in.\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/682-web.png"},"website":"https://www.ericsson.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":685,"name":"Fujitsu Limited","member_since":"2004-04-28","renewal_date":"2027-04-01","description":{"long":"We provide software and services to help companies continuously visualize and optimize their business processes and applications to improve and innovate while creating leaner, more efficient operations. With market conditions changing rapidly, organizations need to be equipped to iteratively develop, deploy, and optimize business processes and applications to meet these business demands - without compromising on business governance."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/685-web.png"},"website":"https://www.fujitsu.com/global/","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Enterprise Member","level":"WGDSA","working_group":"adoptium"},{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":687,"name":"Genuitec, LLC","member_since":"2008-08-31","renewal_date":"2027-01-01","description":{"long":"Genuitec's products enable developers to build anything from anywhere with anyone.\n

\nMyEclipse, our flagship professional IDE, is the world-wide leader in its class for enterprise Java and web development. Premium toolset. Fair pricing.\n

\nCodeTogether, our cross-IDE live sharing system, enables users of Eclipse, VS Code, IntelliJ, and the IDEs based on those, to code together collaboratively using all the tools they prefer.\n

\nDevStyle with Darkest Dark makes millions of Eclipse installations look their very best, in dark or light themes, with stunning custom icons. Free in the marketplace."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/687-web.png"},"website":"https://genuitec.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":690,"name":"EclipseSource","member_since":"2007-03-01","renewal_date":"2027-03-01","description":{"long":"EclipseSource has well over a decade of experience in designing, developing and enhancing tools for a variety of domains and based on all major technology platforms. Whether it is a classic IDE for software engineering, a modeling tool for your domain experts or a domain-specific solution for engineers, whether the tool is a web-based, a desktop-based application, a tool based on Eclipse Theia or a plugin for Eclipse, EclipseSource can support you in implementing the best possible solution for your use case. We provide a complete range of services including conception, evaluation, training, support, and consulting/implementation all with a special focus on framework adoption, creation, and (long-term) maintenance. EclipseSource is a major contributor to a large number of open source projects inside and outside the Eclipse ecosystem. EclipseSource is distributed over multiple locations in Europe and serves a truly global customer base from various domains, ranging from Fortune 100 corporations to individual developers"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/690-web.png"},"website":"https://eclipsesource.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"","level":"WGSM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":721,"name":"Oracle","member_since":"2004-01-27","renewal_date":"2027-02-01","description":{"long":"Oracle\\'s business is information how to manage it, use it, share it, protect it. The world\\'s largest enterprise software company, Oracle is the only vendor to offer solutions for every tier of your business-database, middleware, business intelligence, business applications, and collaboration. With Oracle, you get information that helps you measure results, improve business processes, and communicate a single truth to your constituents.\\r\\n\\r\\nOracle\\'s next-generation enterprise computing platform Fusion is being designed to enable incremental adoption of a powerful, flexible, service-oriented IT infrastructure without the disruption associated with a wholesale platform upgrade. This portfolio is built on powerful Fusion design principles, standardizing the priorities and practices of your enterprise computing strategy-saving you significant time and money."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/721-web.gif"},"website":"https://www.oracle.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":731,"name":"Red Hat, LLC.","member_since":"2005-01-26","renewal_date":"2027-03-01","description":{"long":"Red Hat is the open hybrid cloud technology leader, delivering a trusted, consistent and comprehensive foundation for transformative IT innovation and AI applications. Its portfolio of cloud, developer, AI, Linux, automation and application platform technologies enables any application, anywhere—from the datacenter to the edge. As the world's leading provider of enterprise open source software solutions, Red Hat invests in open ecosystems and communities to solve tomorrow's IT challenges. Red Hat helps its partners and customers build, connect, automate, secure and manage their IT environments, supported by consulting services and award-winning training and certification offerings."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/731-web.png"},"website":"https://www.redhat.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Innovator Member","level":"WGPAA","working_group":"internet-things-iot"},{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"df911e0adcad1a1c51df","description":"","level":"WGPL","working_group":"asciidoc"},{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"},{"document_id":"efcdef5b284754c43de2","description":"Strategic Member","level":"WGSD","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":742,"name":"Thales","member_since":"2009-08-28","renewal_date":"2027-04-01","description":{"long":"Thales is a world leader in mission-critical information systems for defense and security, aerospace and transportation."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/742-web.jpg"},"website":"https://www.thalesgroup.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Strategic Member","level":"WGSD","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":758,"name":"Fraunhofer-Gesellschaft","member_since":"2004-01-01","renewal_date":"2027-02-01","description":{"long":"

The Fraunhofer-Gesellschaft, headquartered in Germany, is the worlds leading applied research organization. With its focus on developing key technologies that are vital for the future and enabling the commercial exploitation of this work by business and industry, Fraunhofer plays a central role in the innovation process. As a pioneer and catalyst for groundbreaking developments and scientific excellence, Fraunhofer helps shape society now and in the future. Founded in 1949, the Fraunhofer-Gesellschaft currently operates 75 institutes and research institutions throughout Germany. The majority of the organizations 29,000 employees are qualified scientists and engineers, who work with an annual research budget of 2.8 billion euros. Of this sum, 2.4 billion euros are generated through contract research.

\\r\\n

For several Fraunhofer institutes, open source plays a vital role in many research areas:

\\r\\n

The Fraunhofer Institute for Open Communication Systems FOKUS offers research services ranging from requirements analysis to consulting, feasibility studies, technology development right up to prototypes and pilots in the business segments Digital Public Services, Future Applications and Media, Quality Engineering, Smart Mobility, Software-based Networks, Networked Security, Visual Computing und Analytics. Fraunhofer FOKUS, for example provides the open source simulation environment Eclipse MOSAIC for testing mobility scenarios. In addition, the institute has contributed an IoT-Testware to Eclipse and is interested in AI, Cloud and Edge activities.

\\r\\n\\r\\n

The Fraunhofer Institute for Intelligent Analysis and Information Systems IAIS is one of the leading scientific institutes in Artificial Intelligence, Machine Learning, and Big Data in Germany and Europe. With its more than 300 employees, the institute supports companies in the optimization of products, services, processes and structures and development of new digital business models.

\\r\\n\\r\\n

The Fraunhofer Institute for Experimental Software Engineering IESE supports the digitization of services, systems, and the development of digital ecosystems. Dedicated to open-source software, we create solutions for virtual engineering, safe systems, and Industry 4.0.

\\r\\n\\r\\n

The Fraunhofer Institute for Software and Systems Engineering ISST focuses on designing and developing data spaces that enable sovereign, secure and controllable data sharing across company boundaries. Therefore, Fraunhofer ISST offers technical design, implementation of system components and consultancy services throughout the entire development process.

\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/758-web.png"},"website":null,"levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"},{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":760,"name":"Object Management Group, Inc.","member_since":"2004-01-01","renewal_date":"2027-01-01","description":{"long":"OMG Task Forces develop enterprise integration standards for a wide range of technologies and an even wider range of industries. OMG\\'s modeling standards enable powerful visual design, execution and maintenance of software and other processes. For more information, visit www.omg.org. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/760-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":800,"name":"STMicroelectronics International N.V.","member_since":"2020-01-01","renewal_date":"2027-01-01","description":{"long":"At ST, we are 48,000 creators and makers of semiconductor technologies mastering the semiconductor supply chain with state-of-the-art manufacturing facilities. An independent device manufacturer, we work with more than 200,000 customers and thousands of partners to design and build products, solutions, and ecosystems that address their challenges and opportunities, and the need to support a more sustainable world. Our technologies enable smarter mobility, more efficient power and energy management, and the wide-scale deployment of the Internet of Things and 5G technology. ST is committed to becoming carbon neutral by 2027. Further information can be found at www.st.com."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/800-web.png"},"website":"https://st.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":816,"name":"Vector Informatik GmbH","member_since":"2006-05-12","renewal_date":"2027-05-01","description":{"long":"

\nVector provides tools, software components and engineering services for the networking of electronic systems in the automobile and related industries.\n

The ECU development is supported with tools for the design, test, calibration and diagnostics as well as with software components and development services.

"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/816-web.png"},"website":"https://www.vector.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Platinum Member","level":"WGPLM","working_group":"eclipse-ide"},{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":823,"name":"ARM Limited","member_since":"2006-08-01","renewal_date":"2027-04-01","description":{"long":"Arm designs the technology that lies at the heart of advanced digital products, from wireless, networking and consumer entertainment solutions to imaging, automotive, security and storage devices.\\r\\n
\\r\\nArm\\'s comprehensive product offering includes 16/32-bit RISC microprocessors, data engines, 3D processors, digital libraries, embedded memories, peripherals, software and development tools, as well as analog functions and high-speed connectivity products.\\r\\n
\\r\\nCombined with the company\\'s broad Partner community, they provide a total system solution that offers a fast, reliable path to market for leading electronics companies. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/823-web.png"},"website":"https://www.arm.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":848,"name":"Advanced Micro Devices (AMD)","member_since":"2007-02-27","renewal_date":"2026-07-01","description":{"long":"Advanced Micro Devices, Inc. (NYSE: AMD) is a global leading provider of processors, chipsets and graphics products. To ensure that these products enable solutions for customers, AMD works with the software community, invests in advancements in the software ecosystem and develops tools and libraries to assist in software development. For more information on AMD's software product, efforts and guidance on software development, visit AMD Developer Central at http://developer.amd.com"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/848-web.jpg"},"website":"https://www.amd.com/en/developer.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"}],"is_active_member":true},{"organization_id":863,"name":"OBEO","member_since":"2007-05-29","renewal_date":"2026-06-01","description":{"long":"Obeo is a software provider, specialized in the model driven approach and a key player of the Eclipse platform. It is an actor of the Open Source ecosystem and a strategic member of the Eclipse Foundation; Obeo is one of the major Eclipse contributors, ranking up as one of the top contributing companies every year since it became a member of the Eclipse Foundation.\\r\\n\\r\\nObeo\\'s primary concerns are to provide open technologies allowing users to master the complexity of systems.\\r\\n\\r\\nIts product range include: Sirius (Graphical Designers), Acceleo (code generator), Obeo Designer (custom graphical modeling environment), collaborative add-ons for Eclipse Capella, Obeo SmartEA (Enterprise Architecture), consulting (training, expertise and coaching), and Eclipse Modeling as a foundation stack of any modeling environment.\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/863-web.png"},"website":"https://www.obeosoft.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":890,"name":"BlackBerry Limited ","member_since":"2007-12-04","renewal_date":"2026-12-01","description":{"long":"QNX Software Systems Limited, a subsidiary of BlackBerry Limited, is a leading provider of operating systems, middleware, professional services, and Eclipse-based development tools for connected embedded systems. Global leaders such as Audi, Siemens, General Electric, Cisco, and Lockheed Martin depend on QNX technology for their in-car electronics, medical devices, industrial automation systems, network routers, and other mission- or life-critical applications. Visit www.qnx.com and follow @QNX_News on Twitter. For updates on the company\\'s automotive work, follow @QNX_Auto and visit qnxauto.blogspot.com."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/890-web.png"},"website":"https://blackberry.qnx.com/en","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":895,"name":"Siemens AG","member_since":"2008-01-16","renewal_date":"2027-02-01","description":{"long":"Siemens is a global powerhouse focusing on the areas of electrification, automation and digitalization. One of the worlds largest producers of energy-efficient, resource-saving technologies, Siemens is a leading supplier of systems for power generation and transmission as well as medical diagnosis. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/895-web.gif"},"website":"https://www.siemens.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"},{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":937,"name":"CEA LIST","member_since":"2008-09-18","renewal_date":"2027-01-01","description":{"long":"List, expert on digital systems
\\r\\n
\\r\\nBased in Saclay (Paris region, France), List is a public research institute specialized in digital systems design. Its main mission is based on achieving excellence technological development on behalf of industrial partners for value creation.
\\r\\n
\\r\\n100 industrial collaborations per year
\\r\\n
\\r\\nList institute counts more than 700 partners and every year more than a 100 partnership activities are being conducted with French and foreign industrial companies on applied research projects in four main topics:\\r\\n
    \\r\\n
  • Advanced Manufacturing
  • \\r\\n
  • Embedded systems
  • \\r\\n
  • Ambient intelligence
  • \\r\\n
  • Health ionizing radiations
  • \\r\\n
\\r\\nLabeled as Carnot Institute , List invests every year 25% of its budget into scientific resourcing actions in order to identify better tomorrows technological breakthroughs.
\\r\\n
\\r\\nCEA Tech as CEA (Commissariat a l\\'energie atomique et aux energies alternatives) Technological Research Division, gathers three specialised technological research institutes among which List institute specialised on digital systems.
\\r\\n
\\r\\nAt a world class state-of-the-art
\\r\\n
\\r\\nOur activity is based on three main pillars\\r\\n
    \\r\\n
  • Scientific excellence
  • \\r\\n\\r\\nList research engineers dedicate a 100% of their time to R&D activities and publish their results into international leading conferences and scientific journals. Keeping a strong link with academic research, they base their research on world-wide state of the art.\\r\\n\\r\\n
  • The Culture of Industry
  • \\r\\n\\r\\nOur research teams are enlightened and motivated by a results-driven culture of projects, fixing themselves clear objectives to reach within committed deadlines and budgets. Each project launched by List Institute is fully assigned to permanent and suited human resources. The project management is based on a precise calendar, identified milestones and a clear description of deliverables.
    \\r\\n\\r\\nResearch results confidentiality and intellectual property (patents) are defined by the parties in the collaboration agreement.\\r\\n\\r\\n
  • Opening to the world
  • \\r\\n\\r\\nList Institute is fully integrated into a local and national particularly dynamic ecosystem through strategic academic, institutional and industrial partnerships. In order to maintain the best level internationally in its fields of activity List institute is also involved in more than 200 European collaborative projects, collaborates with leading foreign academic laboratories and conducts research activities at an international level, especially in the USA."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/937-web.png"},"website":"https://list.cea.fr/en/","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"ecd63e75a561bffe2ffc","description":"Strategic Member","level":"WGSD","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":954,"name":"Business Systems Integration AG","member_since":"2009-03-26","renewal_date":"2027-04-01","description":{"long":"With its BSI Customer Suite, the Swiss software company BSI provides a comprehensive platform for the digital transformation of customer relationships. It offers everything needed for an outstanding customer experience in the retail, banking, insurance and energy & utility industries. At the core of the innovation is the company’s many years of industry experience. Founded in Baden, Switzerland, in 1996, BSI has about 400 employees and 7 additional offices in Germany and Switzerland. BSI’s customers include companies and organizations such as ADAC, Signal Iduna and HDI and other market-leading companies throughout Europe. Visit BSI"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/954-web.png"},"website":"https://www.bsi-software.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":968,"name":"Eurotech","member_since":"2009-12-10","renewal_date":"2027-01-01","description":{"long":"

    Eurotech integrates hardware, software, solutions, and expertise to deliver embedded computing platforms, sophisticated systems and cloud-based services to leading OEMs, system integrators, and enterprise customers for successful, efficient, and speedy deployment of their products and services.

    \n\n

    Eurotech simplifies pervasive computing, allowing our customers to focus on their core competencies, the products and services only they can deliver, while Eurotech lays the embedded computing foundation to bring those offerings to market as quickly as possible. (1) Minimalist computing, drawing on decades of experience in low power design, miniaturization of platforms, and simplification of application development through modular middleware and toolsets, allows our customers to create the most efficient products and services possible. (2) With strengths in wireless services and communications protocols, we deliver the integrated and connected solutions our customers need to simplify the development and deployment of their products and services, even through the cloud. (3) Combining pervasive technology excellence with domain expertise allows Eurotech to meet the pervasive computing needs of five key market segments including healthcare, security, transportation, energy, and industrial. (4) As a trusted business associate to both our customers and our partners, we are committed to the mutual success of all companies in the value chain for networked solutions.

    \n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/968-web.png"},"website":"https://www.eurotech.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Leader Member","level":"WGLM","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":977,"name":"FZI Forschungszentrum Informatik","member_since":"2010-04-12","renewal_date":"2027-04-01","description":{"long":"The FZI Research Centre for Information Technology is an interdisciplinary non-profit research organization, based in Karlsruhe, Germany, whose mission is to facilitate technology transfer of innovative IT solutions and to provide a bridge between academia and industry. FZI offers its customers a unique interdisciplinary environment that fosters joint research among diverse fields of Computer Science, Mechanical and Electrical Engineering, and Economics. \n\nFZI has been a great success story for 25 years now, and using its extensive network of contacts both in the academic and the industrial world, it has been an important catalyst for the development of IT in the Karlsruhe region. \n\nToday, FZI has over 150 employees, mostly young scientists with outstanding experience in both research projects and professional consulting activities.\n\nFZI is a major promoter of Open Source, having among its employees contributors to dozens of open source projects, many of which targeting the Eclipse platform.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/977-web.png"},"website":"https://www.fzi.de","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":979,"name":"Robert Bosch GmbH","member_since":"2010-04-27","renewal_date":"2027-01-01","description":{"long":"The Bosch Group is a global supplier of technology and services. Its operations are divided into four business sectors: Mobility Solutions, Industrial Technology, Consumer Goods, and Energy and Building Technology. Bosch offers innovative solutions for smart homes, Industry 4.0, and connected mobility. Bosch is pursuing a vision of mobility that is sustainable, safe, and exciting, as well as an open approach to the Software Defined Vehicle technology stack of the future in conjunction with its subsidiary ETAS GmbH. The Bosch Group comprises roughly 440 companies in about 60 countries, employing some 76,100 associates in research and development, around half of which are software engineers."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/979-web.png"},"website":"https://bosch.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Leader Member","level":"WGLM","working_group":"internet-things-iot"},{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"},{"document_id":"aea0514f5cc2d0407ffd","description":"Driver Member","level":"WGPAE","working_group":"openpass"},{"document_id":"f348c2873ca8ed8e9eca","description":"Supporting Member","level":"WGSM","working_group":"oniro"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"},{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":989,"name":"Protos Software GmbH","member_since":"2010-06-23","renewal_date":"2026-07-01","description":{"long":"Protos is a service company that specialized in the development of model-driven, domain-specific tools and applications for Embedded Systems.\\r\\n\\r\\nWe develop tools and applications for our customers and support them with training, consulting and coaching. Most of our projects are based on Eclipse Open Source Tools."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/989-web.png"},"website":"https://protos.de","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":990,"name":"Sigasi","member_since":"2010-06-24","renewal_date":"2026-07-01","description":{"long":"Sigasi allows FPGA and ASIC designers in the medical, telecom, automotive, defense, and aerospace worlds to achieve their full potential with a powerful Integrated Development Environment (IDE).\n\nSigasi assists design engineers in writing RTL with a mix of VHDL, Verilog, and SystemVerilog, giving them everything from basic editing to advanced features like autocomplete, code navigation, and linting. Most importantly, Sigasi gives hardware designers real-time feedback.\n\nMoreover, Sigasi integrates with existing workflows, including CI/CD checking, allowing teams to safeguard entire code repositories. This is particularly valuable for ASIC design and optimizing hand-off to verification teams."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/990-web.png"},"website":"https://www.sigasi.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":998,"name":"FUNDACIÓN TECNALIA RESEARCH & INNOVATION","member_since":"2010-09-24","renewal_date":"2027-04-01","description":{"long":"

    TECNALIA is the largest center of applied research and technological development in Spain, a benchmark in Europe and a member of the Basque Research and Technology Alliance. We collaborate with companies and institutions to improve their competitiveness, people’s quality of life and achieve sustainable growth. We do it thanks to people who are passionate about technology and committed to building a better society.

    \n

    Our Mission: To transform technological research into prosperity.

    \n

    Our Vision: To be agents of transformation of companies and society for their adaptation to the challenges of a changing future.

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/998-web.png"},"website":"https://www.tecnalia.com/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Supporter Member","level":"WGSM","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1006,"name":"Yatta Solutions GmbH","member_since":"2010-11-29","renewal_date":"2026-12-01","description":{"long":"Yatta is all about software development, engineering and evolution. We started as a developer tool company, transformed into a software vendor and now help build B2B ecosystems for digital products.\n

    \nWe are open-source project lead of the Eclipse Marketplace Client, package maintainer of the Eclipse IDE for Java Developers, and member of the Eclipse IDE working group. We commit and contribute to various other open-source projects as well.\n

    \nOur goal is to keep and sustain Eclipse as an open ecosystem. That's why we have launched the Yatta Checkout for Eclipse."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1006-web.png"},"website":"https://yatta.de/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1009,"name":"BMW Group","member_since":"2011-01-01","renewal_date":"2027-01-01","description":{"long":"BMW Group is now Eclipse member.\n

    \nThe BMW Group is an automobile manufacturer. With its three brands, BMW, MINI and Rolls-Royce Motor Cars, the BMW Group is focusing on the premium sector of the international automobile market. In addition the BMW Group is also a manufacturer of motorcycles and a provider of financial services.\nSoftware plays an important role in modern cars and is one of the main drivers of innovation in the automobile industry. The Eclipse technology is used by BMW in various forms for the development of in-car electric/electronic (E/E) systems and its accompanying development tasks.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1009-web.png"},"website":"https://www.bmw.com/en/index.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"aea0514f5cc2d0407ffd","description":"Driver Member","level":"WGPAE","working_group":"openpass"},{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1042,"name":"Virtual Vehicle Research GmbH","member_since":"2012-02-03","renewal_date":"2027-02-01","description":{"long":"Virtual Vehicle Research GmbH (ViF) is a holding company of the COMET K2 research program \\\"K2 Digital-Mobility\\\" an international institution in the field of application-oriented vehicle development."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1042-web.jpg"},"website":"https://www.virtual-vehicle.at/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1069,"name":"Renesas Electronics Corporation","member_since":"2012-11-09","renewal_date":"2026-11-01","description":{"long":"Renesas Electronics Corporation, headquartered in Japan, delivers trusted embedded design innovation with complete semiconductor solutions that enable billions of connected, intelligent devices to enhance the way people work and livesecurely and safely.\\r\\n\\r\\nA global leader in microcontrollers, analog, power and SoC products, Renesas provides the expertise, quality, and comprehensive solutions for a broad range of Automotive, Industrial, Home Electronics (HE), Office Automation (OA) and Information Communication Technology (ICT) applications to help shape a limitless future.\\r\\n\\r\\nRenesas Electronics is one of the leading supplier for the global automotive industry and number one supplier of automotive microcontrollers (MCUs) worldwide with advanced semiconductor solutions, including system-on-chip (SoC). \\r\\n\\r\\nWith Renesas autonomyTM, an open, innovative, and trusted platform for assisted and automated driving, Renesas Electronics gives customers the choice to decide the future of driving will look like.\\r\\n\\r\\nRenesas Electronics is dedicated to support big ideas both locally and globally with its subsidiaries in 20 countries worldwide. More information is available at www.renesas.com."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1069-web.png"},"website":"https://www.renesas.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"},{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1077,"name":"University of Skovde","member_since":"2013-02-28","renewal_date":"2027-02-01","description":{"long":"The University of Skovde is one of the most specialised universities in Sweden and our research is focused on the development and use of advanced information technology systems and models. Areas of expertise include organisational and technological aspects of the ICT area. Over a number of years research has addressed various aspects of openness. We have significant experience with research and practice related to different stakeholder roles (including providers, developers and users) related to Open Source and Open Standards. Previous activities include involvement as partner and leader in several international and national research projects. In collaboration with leading academic partners we conducted rigorous research in the EU FP6 CALIBRE project (2004-2006), which involved extensive interaction with European industry and presented a roadmap for future research on the Open Source phenomenon. As partners in the CALIBRE-project, the ITEA-project COSI and the ITEA2-project OPEES, we have experience of international collaboration, and close collaboration with many leading researchers and practitioners in areas related to the Open Source phenomenon. Current activities include research on various aspects of openness impacting on long-term sustainability of software systems with associated digital assets. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1077-web.jpg"},"website":"https://www.his.se/en","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1083,"name":"Robotron Datenbank-Software GmbH","member_since":"2013-06-01","renewal_date":"2026-06-01","description":{"long":"Robotron is an innovative IT service provider specializing in the efficient management and analysis of large volumes of data. We support customers in the energy sector, industry and public administration with practical software solutions that optimize business processes and deliver measurable value across the value chain. Our portfolio is complemented by comprehensive consulting, project and operational services – making us a reliable partner who understands both technologies and industry-specific processes."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1083-web.jpg"},"website":"https://www.robotron.eu","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1090,"name":"Open Source Automation Development Lab (OSADL)","member_since":"2022-07-27","renewal_date":"2027-04-01","description":{"long":"The Open Source Automation Development Lab (OSADL) eG is a community for Open Source software in industry and delivers everything a company needs to successfully use Open Source software and especially Linux in industrial products and generally in embedded systems in an efficient and license compliant way. \n\nOSADL is a registered cooperative and accepts members from all over the world. The economical advantage of an OSADL membership is based on the principle of OSADL’s business model: Develop once for the use of many. \n\nMore information at: https://www.osadl.org"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1090-web.png"},"website":"https://www.osadl.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1105,"name":"Lablicate GmbH","member_since":"2013-12-01","renewal_date":"2026-12-01","description":{"long":"Lablicate GmbH is the company behind OpenChrom. Our expertise is software in general and Eclipse technology in special in combination with knowledge of various techniques used in analytical chemistry and related areas. The combination of IT- and Science Know-How is our strength. We are experienced using the benefits of both world."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1105-web.png"},"website":"https://www.lablicate.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1106,"name":"AMIQ EDA","member_since":"2013-12-09","renewal_date":"2026-12-01","description":{"long":"AMIQ EDA provides software tools that enable hardware design and verification engineers to increase the speed and quality of new code development, simplify legacy code maintenance, accelerate language and methodology learning, and improve source code reliability."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1106-web.jpg"},"website":"https://www.amiq.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1122,"name":"HiveMQ GmbH","member_since":"2014-05-06","renewal_date":"2027-05-01","description":{"long":"HiveMQ helps companies connect devices to the Internet. Our HiveMQ MQTT platform makes it possible to move data from device to cloud in a secure, reliable and scalable manner. Over 130 customers, including many Fortune 500 companies, rely on HiveMQ in production for mission critical use cases like connected cars, transportation, logistics, Industry 4.0 and connected IoT products. Visit hivemq.com for more details."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1122-web.png"},"website":"https://www.hivemq.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Innovator Member","level":"WGPAA","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1125,"name":"Kichwa Coders Canada Inc.","member_since":"2014-05-14","renewal_date":"2027-05-01","description":{"long":"Kichwa Coders is a software consultancy specialising in Eclipse open source software for scientific and embedded applications. We help companies adopt and make the most out of open source software."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1125-web.png"},"website":"https://www.kichwacoders.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"","level":"WGSM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1134,"name":"Mercedes-Benz Tech Innovation GmbH","member_since":"2014-06-18","renewal_date":"2027-01-01","description":{"long":"We develop IT for tomorrow's mobility: We are a fully owned subsidiary of Mercedes-Benz Group AG. As an equal IT partner, we work within the Mercedes-Benz Group AG to shape the digital path to future mobility."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1134-web.png"},"website":"https://www.mercedes-benz-techinnovation.com/","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"aea0514f5cc2d0407ffd","description":"Driver Member","level":"WGPAE","working_group":"openpass"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1135,"name":"Canonical Group Limited","member_since":"2014-06-12","renewal_date":"2026-06-01","description":{"long":"

    Canonical is the company behind Ubuntu, the leading OS for container, cloud, scale-out and hyperscale computing. 65% of large-scale OpenStack deployments are on Ubuntu, using both KVM and the pure-container LXD hypervisor for the worlds fastest private clouds. Canonical provides enterprise support and services for commercial users of Ubuntu.

    \\r\\n\\r\\n

    Canonical leads the development of Juju, the model-driven operations system, and MAAS (Metal-as-a-Service), which creates a physical server cloud and IPAM for amazing data centre operational efficiency. Established in 2004, Canonical is a privately held company.

    \\r\\n\\r\\n

    Canonical leads the development of the snap universal Linux packaging system for secure, transactional device updates and app stores. Ubuntu Core is an all-snap OS, perfect for devices and appliances. Established in 2004, Canonical is a privately held company.

    \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1135-web.png"},"website":"https://www.ubuntu.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Enterprise Member","level":"WGDSA","working_group":"adoptium"},{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1138,"name":"Universite Grenoble Alpes (UGA)","member_since":"2014-07-03","renewal_date":"2026-07-01","description":{"long":"As the world is becoming more and more competitive, our institution aims to better respond to the challenges the world poses universities today and in the future, and to be more visible and attractive internationally.\\r\\n\\r\\nThe Universit Grenoble Alpes already features in the top 100 and top 200 universities in major international rankings (Reuters, Shanghai, Times Higher Education and QS for example) for some of its scientific fields. The UGA rivals the best universities in the world thanks to the strength of its research and the numerous educational innovations it has implemented."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1138-web.png"},"website":"https://www.univ-grenoble-alpes.fr/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1144,"name":"DB Systel GmbH","member_since":"2014-08-01","renewal_date":"2027-03-01","description":{"long":"

    \\r\\nDB Group offers globally mobility and logistical services and operates in over 130 countries world-wide. Every day, more than 300,000 employees, of which about 195,000 are located in Germany, are committed to ensuring that customers are provided with mobility and logistical services and that the related rail, road, ocean and air traffic networks are operated and controlled efficiently.\\r\\n

    \\r\\n

    \\r\\nThe companys core business is the railway in Germany with more than 5,5 million customers every day in the passenger transport segment, and about 596 thousand tons of freight shipped via rail. More than 1.8 million customers travel via DB buses in Germany every day. Deutsche Bahn operates more than 40,000 train runs daily on its more than 33,300 kilometer-long, modern rail network, which is also open to competition. The number of train stations is 5.681.\\r\\n

    \\r\\n

    \\r\\nFrom electronic signal boxes to online ticketing and computerized route planning \\r\\noperating today\\'s highly complex mobility and traffic networks is simply unimaginable\\r\\nwithout information and communication technology (ICT). DB Systel, a wholly owned subsidiary of the DB Group, is the digitalisation partner for all Deutsche Bahn companies. As an integrated and value-adding company within the DB Group, DB Systel offers a comprehensive range of customised solutions and services that meets the highest IT standards and picks up on the latest trends. It does so by incorporating its extensive railway and IT expertise and, as a long-term vendor-neutral partner, by pursuing the Groups common objective.\\r\\n

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1144-web.png"},"website":"https://www.dbsystel.de/dbsystel","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1147,"name":"Mueller-BBM VibroAkustik Systeme GmbH","member_since":"2014-10-01","renewal_date":"2026-10-01","description":{"long":"As one of the world\\'s leading suppliers of vibroacoustic measurement technology, Mueller-BBM VibroAkustik Systeme is focussed on the acquisition, analysis, evaluation and management of dynamic data. \nOur tight partnership with the various industries as well as our recognized expertise in acoustics and vibration results in innovative solutions and establishes us as a strong partner for your noise, vibration and harshness (NVH) measurement and analysis requirements. Our PAK system seamlessly integrates into laboratory, production and field environments."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1147-web.png"},"website":"https://www.mbbm-vas.com/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1156,"name":"Neuron Engineering Tools GmbH","member_since":"2015-01-08","renewal_date":"2027-01-01","description":{"long":"Neuron Engineering Tools GmbH, with locations in Austria, Germany and Hungary, has been developing software tools and platforms for industrial automation since 1987. Key solutions include the IEC 61131-3 programming system of the Neuron Engineer series, the portable runtime system RTS (scalable from microcontrollers to multi-core IPCs), and the documentation tool logi.DOC. Over 30,000 engineers worldwide use Neuron software to automate systems such as power plants, steel mills, machines, and more — creating, testing, and managing efficient, high-quality solutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1156-web.png"},"website":"https://www.neuron-automation.eu/en","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1164,"name":"Gradle Inc","member_since":"2015-02-24","renewal_date":"2027-03-01","description":{"long":"Gradle Inc. is the company behind the leading software solution for improving developer productivity called Gradle Enterprise and the popular open-source Java build automation system called Gradle Build Tool.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1164-web.png"},"website":"https://gradle.org","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1166,"name":"Azul Systems, Inc","member_since":"2015-05-07","renewal_date":"2027-05-01","description":{"long":"Azul Systems is the world\\'s only company that is 100% focused on Java and Java runtime technology. We believe that we can help the IoT developers take advantage of the power and productivity of Java by reducing the frictions (licensing costs, field-of-use restrictions) and perceptions (footprint, etc.) gating widespread adoption of the language throughout the IoT.\nAs members of the Eclipse community we are bringing Zulu and Zulu Embedded - our 100% open source JDKs, to the IoT. Our Zulu products are certified builds of OpenJDK and meet the Java SE standards for Java 8, 7 and 6. Each release of Zulu and Zulu Embedded has passed the thousands of tests in OpenJDK Technology Compatibility Kit (TCK) as well as extensive in-house verification suite. Zulu runs on many Linux distros, on Windows and the Mac.\nZulu is a complete Java Development Kit, and Zulu Enterprise provides designers with a choice of storage footprint, bitness (32 or 64-bit configurations), headless or headful, and both development and runtime-only options.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1166-web.jpg"},"website":"https://www.azul.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1194,"name":"TypeFox GmbH","member_since":"2016-02-02","renewal_date":"2027-02-01","description":{"long":"TypeFox is a team of software pioneers building the languages and IDEs that modern engineering teams rely on. We’re the inventors behind open source projects such as Langium, Theia, Sprotty, and Open VSX — technologies that have become the backbone of custom development environments and domain-specific tooling across industries.\n\nWe help projects move from idea to working product with clarity and technical depth. Whether it’s a cloud-ready IDE, a tailored DSL, or a complex graph visualization, we build solutions that adapt to your workflows instead of the other way around. And because our technology base is open source, you benefit from extensible foundations designed for long-term impact."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1194-web.png"},"website":"https://www.typefox.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"f348c2873ca8ed8e9eca","description":"Supporting Member","level":"WGSM","working_group":"oniro"}],"is_active_member":true},{"organization_id":1196,"name":"Microsoft Corp.","member_since":"2016-01-15","renewal_date":"2026-06-01","description":{"long":"At Microsoft, our developer mission is to deliver experiences that empower any developer, building any application, on any OS. And this mission requires us to be open, flexible, and interoperable: to meet developers and development teams where they are, and provide tools, services and platforms that help them take ideas into production. Supporting the Eclipse Foundation enables us to collaborate more closely with the Eclipse community, deliver a great set of tools and services for all development teams, and continuously improve our cloud services, SDKs and tools."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1196-web.png"},"website":"https://www.microsoft.com/","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"},{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"},{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Enterprise Member","level":"WGDSA","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Strategic Member","level":"WGSD","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1208,"name":"Universitat Oberta De Catalunya","member_since":"2016-04-07","renewal_date":"2027-04-01","description":{"long":"

    A state-of-the art technological university with a highly innovative learning model, providing a benchmark for quality in both teaching and R&D. This is the philosophy of the Universitat Oberta de Catalunya (UOC, Open University of Catalonia), created in 1994 as one of the worlds very first completely online higher education establishments and that currently has more than 50,000 students.

    \\r\\n

    The UOCs core goal is to be the university of the knowledge society, promoting innovative education, personalised learning, technological leadership, R&D work on the information society and e-learning and the dissemination of knowledge. The UOC promotes R&D activities via 10 groups linked the Internet Interdisciplinary Institute (IN3), specialising in the study of the networked society and the knowledge economy, network technologies and specific software areas. Over the last five years, the UOC has participated in more than 260 R&D projects, either national or European. What is more, the UOC works to promote knowledge transfer and has, over the last four years, signed more than 1000 agreements to this end. The UOC forms part of more than 30 international networks, including the European University Association (EUA), the International Council for Open and Distance Education (ICDE) and the IMS Global Learning Consortium

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1208-web.png"},"website":"https://www.uoc.edu/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1219,"name":"Fondazione Bruno Kessler","member_since":"2016-10-04","renewal_date":"2026-10-01","description":{"long":"Fondazione Bruno Kessler - FBK - is a private no profit research institution based in Trento, Italy. \\r\\nFBK is divided in several centres and its mission is to develop both knowledge and expertise in the fields of Information and Communication Technology, Microsystems/Microelectronics and Social science, aiming to conduct technology transfer at the local, national and international industrial level. \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1219-web.png"},"website":"https://www.fbk.eu/en/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1220,"name":"Salesforce.com, Inc.","member_since":"2016-10-05","renewal_date":"2027-01-01","description":{"long":"Salesforce is a customer relationship management solution that brings companies and customers together. It\\'s one integrated CRM platform that gives all your departments including marketing, sales, commerce, and service a single, shared view of every customer."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1220-web.png"},"website":"https://opensource.salesforce.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"}],"is_active_member":true},{"organization_id":1221,"name":"Webtide LLC","member_since":"2016-10-10","renewal_date":"2026-10-01","description":{"long":"Webtide was founded with one goal in mind: to provide the very best service and support for developer teams of all sizes who want to work with Eclipse Jetty and CometD. Whether your project is small or large, weve worked with companies around the world to make sure that their Jetty and CometD projects are a success.\\r\\n\\r\\nUnlike some other software companies, Webtides focus is on service, not on growth we value stability over size. We dont over-promise or under-deliver; our support is terrific and our products do just what they say theyll do. We have worked with some of the biggest names in technology and have a portfolio of satisfied customers. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1221-web.png"},"website":"https://webtide.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1228,"name":"OFFIS e.V","member_since":"2016-11-11","renewal_date":"2026-11-01","description":{"long":"Knowlegdge Transfer

    A fast knowledge transfer from research into the economy is the crucial foundation for the economic, as well as the social well-being of a country. We have made this transfer our task: As an associated institute of the Carl von Ossietzky University in Oldenburg, OFFIS has, since its formation in 1991, converted scientific know-how from computer science into prototypes which are then developed further into marketable products by commercial partners. Hereby, OFFIS provides research and prototype developments for companies and institutions and this at the highest international level."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1228-web.png"},"website":"https://www.offis.de/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1235,"name":"Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR)","member_since":"2017-01-02","renewal_date":"2027-01-01","description":{"long":"

    \\r\\nDLR is the national aeronautics and space research centre of the Federal Republic of Germany. Its extensive research and development work in aeronautics, space, energy, transport and security is integrated into national and international cooperative ventures. In addition to its own research, as Germanys space agency, DLR has been given responsibility by the federal government for the planning and implementation of the German space programme. DLR is also the umbrella organisation for the nations largest project management agency.\\r\\n

    \\r\\n

    \\r\\nDLR has approximately 8000 employees at 20 locations in Germany: Cologne (headquarters), Augsburg, Berlin, Bonn, Braunschweig, Bremen, Bremerhaven, Dresden, Goettingen, Hamburg, Jena, Juelich, Lampoldshausen, Neustrelitz, Oberpfaffenhofen, Oldenburg, Stade, Stuttgart, Trauen, and Weilheim. DLR also has offices in Brussels, Paris, Tokyo and Washington D.C.\\r\\n

    \\r\\n

    \\r\\nDLRs mission comprises the exploration of Earth and the Solar System and research for protecting the environment. This includes the development of environment-friendly technologies for energy supply and future mobility, as well as for communications and security. DLRs research portfolio ranges from fundamental research to the development of products for tomorrow. In this way, DLR contributes the scientific and technical expertise that it has acquired to the enhancement of Germany as a location for industry and technology. DLR operates major research facilities for its own projects and as a service for clients and partners. It also fosters the development of the next generation of researchers, provides expert advisory services to government and is a driving force in the regions where its facilities are located.\\r\\n

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1235-web.png"},"website":"https://www.dlr.de/DE/Home/home_node.html","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1238,"name":"Payara Services Limited","member_since":"2017-01-31","renewal_date":"2027-02-01","description":{"long":"Payara Server - Robust, Reliable, Supported\\r\\n

    \\r\\nPayara Server is a fully supported, developer-friendly, open source application server. Payara Servers architecture is innovative, cloud-native and optimized for production deployments.\\r\\n

    \\r\\nMonthly releases, bug fixes and a 10-year support lifecycle optimizes Payara Server for production deployments. Payara Server is aggressively compatible with common ecosystem components and ensures future compliance with Jakarta EE. \\r\\n

    \\r\\nThe application server, compatible with Eclipse MicroProfile, is built and supported by a team of DevOps engineers dedicated to the continued development and maintenance of the open source software and committed to optimizing Payara Server as the best option for production Java EE applications.\\r\\n

    \\r\\n

    \\r\\nPayara Micro - Small, Simple, Serious\\r\\n

    \\r\\nPayara Micro is the open source, lightweight middleware platform of choice for containerized Java EE (Jakarta EE) microservices deployments. Less than 70MB in size, Payara Micro requires no installation or configuration and no need for code rewrites so you can build and deploy a fully working app within minutes.\\r\\n

    \\r\\nCompatible with Eclipse MicroProfile, Payara Micro is the microservices-ready version of Payara Server. You can run war files from the command line without any application server installation. Automatic and elastic clustering makes Payara Micro ideal for running Java EE applications in a modern virtualized infrastructure.\\r\\n

    \\r\\nPayara Micro also comes with a Java API so it can be embedded and launched from your own Java applications.\\r\\n

    \\r\\n

    \\r\\nPayara Enterprise - Software. Security. Stability. Support.\\r\\n

    \\r\\nPayara Enterprise lets you decide when to migrate from one release to the next with a 10-year support lifecycle and access to extra release streams. Youll maintain the security and stability of your applications environment from the JVM on up.\\r\\n

    \\r\\nOur global engineers go beyond the support help desk, offering fast issue resolution and 24-hour support options for your production Payara Server environment, while also giving customers priority on bug fixes and new features requests.\\r\\n

    \\r\\nPayara Enterprise customers enjoy a choice of 105 or 247 support, unlimited tickets, access to a private customer knowledge base and use of fully-supported builds of OpenJDK through our partnership with Azul."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1238-web.png"},"website":"https://www.payara.fish/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1239,"name":"SSI Schaefer IT Solutions GmbH","member_since":"2017-02-09","renewal_date":"2027-02-01","description":{"long":"

    The SSI Schaefer Group is the worlds leading provider of modular warehousing and logistics solutions. It employs approximately 10,500 people at its group headquarters in Neunkirchen (Germany), at more than ten domestic and international production sites, and at approximately 70 worldwide operative subsidiaries. Across six continents, SSI Schaefer develops and implements innovative industry-specific answers to its customers unique challenges. As a result, it plays a key role in shaping the future of intralogistics.

    \\r\\n\\r\\n

    SSI Schaefer designs, develops and manufactures systems for warehouses, industrial plants, workshops and offices. Its portfolio includes manual and automated solutions for warehousing, conveying, picking and sorting, plus technologies for waste management and recycling. In addition, SSI Schaefer is now a leading provider of modular, regularly updated software for in-house material flows. Its IT team, with a headcount in excess of 1,100, develops high-performance applications, and provides customers with in-depth advice on the intelligent combination of software with intralogistics equipment. SSI Schaefers broad IT offering, including its own WAMAS and SAP products, delivers seamless support for all warehouse and material flow management processes. Solutions from SSI Schaefer improve the productivity and efficiency of customer organizations not least through the highly precise monitoring, visualization and analysis of operational metrics for proactive intralogistics management.

    \\r\\n\\r\\n

    SSI Schaefer offers highly sophisticated, turnkey systems. As an international player, it can deliver one-stop solutions to all four corners of the earth. Its comprehensive portfolio encompasses design, planning, consulting, and customer-specific aftersales services and maintenance.

    \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1239-web.png"},"website":"https://www.ssi-schaefer.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1244,"name":"Associacao de Usuarios da Tecnologia Java, SouJava","member_since":"2017-03-14","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1244-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1246,"name":"PTA GmbH","member_since":"2017-04-10","renewal_date":"2027-04-01","description":{"long":"The range of services of the PTA GmbH meets the requirements of digitalization for companies in various industries (ranging from process management, ERP, CRM and industry systems to the development of individual software and hosting solutions \\\"Made in Germany\\\" as well as IT security). Since 1969, the PTA Group has been working with more than 400 employees for long-term customer and employee relationships and is distinguished by its independence from capital markets and manufacturers as a family-run company."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1246-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1248,"name":"Tomitribe Corporation","member_since":"2017-05-01","renewal_date":"2027-05-01","description":{"long":"It\\'s Tomitribe\\'s mission to provide support for consumers, educate people on TomEE, Open Source and Java EE and contribute to the success of everyone in the community. We believe Open Source is an ecosystem and everyone in that ecosystem has a role to play, from the people who produce it to the companies who use it.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1248-web.png"},"website":"https://tomitribe.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1251,"name":"M3S Research Unit at the University of Oulu","member_since":"2017-06-06","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1251-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1269,"name":"Calypso Networks Association","member_since":"2017-12-20","renewal_date":"2027-01-01","description":{"long":"Calypso technology has been designed to ensure interoperability between transportation networks equipments and is open to all manufacturers providers. It has been deployed for 20 years in 25 countries without any hacking reported since now and work with any kind of NFC portable objects: Smart Cards, Secures elements, Sim cards or HCE in Smart Phones.\\r\\n\\r\\nCNA is established in Brussels and has been founded in 2003, with the founder members of the european Calypso project : \\r\\nOTLIS, Ticketing operator of Lisbon\\r\\nACTV, Transport operator of Venice\\r\\nSTIB, Transport operator of Brussels\\r\\nLKRKN, Landrat of Constance\\r\\nRATP, Transport operator of Paris area\\r\\nSNCF, French national trainrail\\r\\n\\r\\nCNA is open to all actors playing a role in the Calypso environment, whether they are user of Calypso or a provider of Calypso. CNA has 80 active members and its main objectives are to define and direct the reference specifications, to implement a certification policy, to guarantee the compatibility of all current and future product, to establish a Calypso label issued by an independent organization, to promote Calypso to operators and manufacturers to yield its distribution, to contribute to the international standardization process, to facilitate and harmonize the shared members\\' needs and expriences. \\r\\n\\r\\nCNA is currently working on developping a full open source SDK for generic contactless Ticketing, which provides a library functions to developers, manages security and masks the complexity of a Calypso transaction.\\r\\n\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1269-web.png"},"website":"https://www.calypsonet-asso.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1286,"name":"Kynetics","member_since":"2018-03-21","renewal_date":"2027-04-01","description":{"long":"Kynetics offers a suite of Android and Linux operating systems (OS) for embedded systems, featuring popular application processors from NXP, Qualcomm, Mediatek and NVIDIA.\nKynetics empowers embedded system providers and manufacturers by offering a also comprehensive suite of products on top of its engineering services.\nDevelopment Tools for extending and simplifying the development and deployment process, allowing engineers to focus on core functionalities of their embedded applications.\nUpdate Factory enables secure and efficient remote updates and management of remote devices. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1286-web.png"},"website":"https://www.kynetics.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Innovator Member","level":"WGPAA","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1308,"name":"The Cloud Native Computing Foundation","member_since":"2018-04-26","renewal_date":"2027-05-01","description":{"long":"Cloud native technologies empower organizations to build and run\\r\\nscalable applications in modern, dynamic environments such as public,\\r\\nprivate, and hybrid clouds. Containers, service meshes, microservices,\\r\\nimmutable infrastructure, and declarative APIs exemplify this\\r\\napproach.\\r\\n\\r\\nThese techniques enable loosely coupled systems that are resilient,\\r\\nmanageable, and observable. Combined with robust automation, they\\r\\nallow engineers to make high-impact changes frequently and predictably\\r\\nwith minimal toil.\\r\\n\\r\\nThe Cloud Native Computing Foundation seeks to drive adoption of this\\r\\nparadigm by fostering and sustaining an ecosystem of open source,\\r\\nvendor-neutral projects. We democratize state-of-the-art patterns to\\r\\nmake these innovations accessible for everyone."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1308-web.png"},"website":"https://www.cncf.io/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1309,"name":"London Jamocha Community","member_since":"2017-01-09","renewal_date":"2027-05-01","description":{"long":"The LJC is a broad community of technologists and other associate with Java and JVM related technologies. Although it is based in London, UK - it has strong international membership due to its global programmes (such as Adopt a JSR and Adopt OpenJDK).\\r\\n\\r\\nThe LJC hosts regular events including:\\r\\n\\r\\n
      \\r\\n
    • Casual catch-ups in a cafe
    • \\r\\n
    • Hack days, evening talks
    • \\r\\n
    • un-conferences
    • \\r\\n
    • workshops
    • \\r\\n
    • mentoring
    • \\r\\n
    • demo days
    • \\r\\n
    • career mentoring by Londons Java specialists
    • \\r\\n
    • and much more!
    • \\r\\n
    \\r\\n\\r\\nThe LJC acts as a voice for Java engineers in London UK as well as globally. This includes but is not limited to helping run a build farm for Java, representing Java developers worldwide on the JCP (aka the Java standards body) as well as the Jakarta EE and MicroProfile communities."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1309-web.png"},"website":"https://www.meetup.com/Londonjavacommunity/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1310,"name":"Cirrus Link Solutions , LLC","member_since":"2018-05-01","renewal_date":"2027-05-01","description":{"long":"Cirrus Link Solutions provide secure and reliable IIOT software solutions enabled with MQTT that integrates process information throughout the organization bridging the IT / OT gap while supplying a superior OT solution. \\r\\n

    \\r\\nWith over 30 years of SCADA and Telemetry experience and the co-inventor of MQTT where M2M and IoT started, Cirrus Links understands the technology requirements to help companies achieve their business objectives. Our experiences and ingenuity has been integral in developing the technology to enable and effectively manage data assets for real-time controls to big data analytics for AI and predictive maintenance. We pride ourselves with our software delivering real solutions for IIOT and SCADA that are tried, tested and ready for production today.\\r\\n

    \\r\\nCirrus Link puts your business data to work faster and smarter. Break out of the information silo created by traditional software and use machines to share in real time with anyone in your company. With Cirrus Link machine to machine (M2M) technology, your people get on-time, real-time access to critical information. Allowing your business can make more informed, smarter decisions.\\r\\n

    \\r\\nLearn more at www.cirrus-link.com"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1310-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1312,"name":"Istanbul JUG","member_since":"2018-05-02","renewal_date":"2027-05-01","description":{"long":"The JUG IST acts as a voice for software engineers in Turkey as well as globally. The JUG Istanbul is a non-profit, big community of technologists associated with Java and JVM related technologies based in Istanbul, Turkey. List of our activities;\\r\\n\\r\\n

    \\r\\n
      \\r\\n
    • JavaDay Istanbul
    • \\r\\n
    • meetups, evening talks
    • \\r\\n
    • un-conferences
    • \\r\\n
    • workshops
    • \\r\\n
    • mentoring
    • \\r\\n
    • coding sessions
    • \\r\\n
    \\r\\n

    \\r\\nand much more!\\r\\n\\r\\nTwitter: @jug_istanbul\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1312-web.png"},"website":"https://www.jugistanbul.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1317,"name":"Inductive Automation","member_since":"2018-06-08","renewal_date":"2026-06-01","description":{"long":"Inductive Automation creates industrial software that empowers organizations to swiftly turn great ideas into reality by removing all technological and economic obstacles. \\r\\n\\r\\nBy cross-pollinating IT with SCADA technologies, Inductive Automation created Ignition software, the first universal industrial application platform with unlimited potential. Ignition empowers industrial organizations around the world and in virtually every industry, with an outstanding software platform and top-notch support."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1317-web.png"},"website":"https://inductiveautomation.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1319,"name":"Karakun AG","member_since":"2018-07-04","renewal_date":"2026-07-01","description":{"long":"Karakun is a growing team of very experienced software engineers developing agilely custom solutions for enterprises offering an optimal user experience. This includes portals (B2E, B2B, B2C), dashboards, and specialized solutions for numerous industries.\\r\\n\\r\\nOur offering includes full-stack development of custom software solutions especially for the cloud. Consequently, we are also engaging with activities around Jakarta EE.\\r\\n\\r\\nWe especially deliver platforms and applications for the integrated management of measurement data to our customers. Therefore, we are contributing to the openMDM working group (https://www.openmdm.org/) and its associated projects.\\r\\n\\r\\nAnd, finally, Karakun offers technology and solutions for semantic enterprise search with high security requirements."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1319-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1320,"name":"Liferay International Limited","member_since":"2025-05-06","renewal_date":"2027-05-01","description":{"long":"Liferay makes software that helps companies create digital experiences on web, mobile and connected devices. Our platform is open source, which makes it more reliable, innovative and secure. We try to leave a positive mark on the world through business and technology. Hundreds of organizations in financial services, healthcare, government, insurance, retail, manufacturing and multiple other industries use Liferay."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1320-web.png"},"website":"https://www.liferay.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1321,"name":"iJUG Interessenverbund der Java-User Groups e V","member_since":"2018-07-10","renewal_date":"2026-07-01","description":{"long":"The interest group of Java User Groups iJUG e.V. is a coalition of approximately 40 Java User Groups from Germany, Switzerland and Austria. The organization promotes the common interests of its members to developers, manufacturers, distributors and the general public."},"logos":{"print":"https://membership.eclipse.org/organization/images/1321-print.eps","web":"https://membership.eclipse.org/organization/images/1321-web.png"},"website":"https://www.ijug.eu/en/home/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Participant Member","level":"WGAPS","working_group":"adoptium"},{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1329,"name":"Advantest Europe GmbH","member_since":"2018-08-10","renewal_date":"2026-08-01","description":{"long":"A world-class technology company, Advantest is the leading producer of automatic test equipment (ATE) for the semiconductor industry and a premier manufacturer of measuring instruments used in the design and production of electronic instruments and systems. Its leading-edge systems and products are integrated into the most advanced semiconductor production lines in the world. The company also focuses on R&D for emerging markets that benefit from advancements in nanotech and terahertz technologies, and has introduced multi-vision metrology scanning electron microscopes essential to photomask manufacturing, as well as groundbreaking 3D imaging and analysis tools. Founded in Tokyo in 1954, Advantest established its first subsidiary in 1982, in the USA, and now has subsidiaries worldwide. More information is available at www.advantest.com."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1329-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1330,"name":"kuehn & weyh Software GmbH","member_since":"2018-09-01","renewal_date":"2026-09-01","description":{"long":"kwsoft is a medium-sized software manufacturer and solution provider, with corporate headquarters in Freiburg, Germany.\\r\\n

    \\r\\nThe CCM solution Serie M/ enables high-quality customer communication that is precisely tailored to the recipient in terms of content, form and medium. The solution gives administrators the greatest possible control over their document processes because it offers a standardized solution from a single vendor - from document composition and creation to multichannel output management."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1330-web.png"},"website":"https://kwsoft.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1339,"name":"OpenDevise Inc","member_since":"2018-12-29","renewal_date":"2027-01-01","description":{"long":"

    OpenDevise helps organizations achieve faster growth through better documentation.

    \\r\\n

    OpenDevise: Tools. Workflows. Information Architecture.

    \\r\\n

    We develop automated tools and build processes that take the complexity, human effort, and anxiety out of deploying documentation sites. OpenDevise is the creator of Antora, a documentation site generator that enables technical writers to create, manage, remix, and publish documentation sites from AsciiDoc-based content sourced from a selection of versioned content repositories.

    \\r\\n

    DevOps for Documentation Teams

    \\r\\n

    We upgrade documentation teams to a modern, agile workflow for creating, reviewing, testing, and publishing documentation composed in the lightweight markup language AsciiDoc. As the maintainers of the leading AsciiDoc processor, Asciidoctor, we have a deep understanding of how to best integrate and adapt AsciiDoc into your documentation teams workflow. OpenDevise helps teams save time, minimize risk, and increase their writing and publishing productivity. A few of the ways we assist are through toolchain configuration, publishing pipeline architecture, UI design, and extension development.

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1339-web.png"},"website":"https://opendevise.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"df911e0adcad1a1c51df","description":"","level":"WGPL","working_group":"asciidoc"}],"is_active_member":true},{"organization_id":1345,"name":"Linux Foundation","member_since":"2019-04-02","renewal_date":"2027-04-01","description":{"long":"Founded in 2000, the Linux Foundation is supported by more than 1,000 members and is the worlds leading home for collaboration on open source software, open standards, open data, and open hardware. Linux Foundations projects are critical to the worlds infrastructure including Linux, Kubernetes, Node.js, and more. The Linux Foundations methodology focuses on leveraging best practices and addressing the needs of contributors, users and solution providers to create sustainable models for open collaboration. For more information please visit us at www.linuxfoundation.org."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1345-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1349,"name":"Eteration A.S","member_since":"2019-05-31","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1349-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1352,"name":"AVL List GmbH","member_since":"2019-06-17","renewal_date":"2026-07-01","description":{"long":"AVL is the world\\'s largest independent company for the development, simulation and testing of powertrain systems (hybrid, combustion engine, transmission, electric drive, batteries, fuel cell and control technology) for passenger cars, commercial vehicles, construction, large engines and their integration into the vehicle. The company has decades of experience in the development and optimization of powertrain systems for all industries. As a global technology leader, AVL provides complete and integrated development environments, measurement and test systems as well as state-of-the-art simulation methods. As a pioneer in the field of innovative solutions, such as diverse electrification strategies for powertrains, AVL is increasingly taking on new tasks in the field of autonomous driving, especially on the basis of subjective human sensations (driveability, connectivity, ADAS, etc.). In the competition of technologies internal combustion engine, battery/electric drive and fuel cell and their combinations, AVL is working intensively and with the same priorities. AVL has digitized the vehicle development process with state-of-the art and highly scalable IT, software and technology platforms, and creates new customer solutions in the areas of big data, artificial intelligence, simulation and embedded systems in an agile and integrated development environment."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1352-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1367,"name":"Information Systems & Databases (DBIS,Informatik 5) of RWTH Aachen University","member_since":"2024-03-12","renewal_date":"2027-03-01","description":{"long":"Across the world and for many decades, the Laboratory for Machine Tools and Production Engineering (WZL) of RWTH Aachen University has stood for successful and forward-thinking research and innovation in the area of production engineering.\\r\\n\\r\\nUnder the leadership of four professors, Thomas Bergs, Christian Brecher, Robert Schmitt and Guenther Schuh, the WZL is conducting research in six areas - production technology, machine tools, production systems, transmission technology, production metrology and quality management - on the future-oriented design of production in high-wage countries. \\r\\n\\r\\nTogether with industry partners from various sectors, the WZL develops solutions for a wide variety of production scenarios in both publicly funded and bilateral projects. \\r\\n\\r\\nThese activities are being consolidated on the RWTH Aachen Campus in the Cluster Production Engineering."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1367-web.png"},"website":"https://www.wzl.rwth-aachen.de/go/id/sijq/?lidx=1","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1374,"name":"Lulea University of Technology","member_since":"2019-09-25","renewal_date":"2026-10-01","description":{"long":"Lule University of Technology is experiencing strong growth with world-leading competence in several areas of research. Our research is conducted in close collaboration with industries such as Bosch, Ericsson, Scania, LKAB, SKF and leading international universities. Lule University of Technology has a total turnover of 190M per year. We currently have 1800 employees and 16 500 students.\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1374-web.png"},"website":"https://www.ltu.se/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1376,"name":"Cedalo GmbH","member_since":"2019-10-07","renewal_date":"2026-10-01","description":{"long":"Streamsheets are a powerful no-code platform to build applications for industrial automation, connectivity and event stream processing.\\r\\n\\r\\nThanks to the familiar spreadsheet user interface also non-programmers create full-fledged applications and services to process data from machines, sensors, apps, APIs and more. With Streamsheets users build customized digital solutions on the edge, on-premises and in the cloud. \\r\\n\\r\\nThe Mosquitto Project is one of the most popular Message Brokers and highly suitable for a broad range of application areas in the Internet of Things and beyond."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1376-web.png"},"website":"https://cedalo.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1380,"name":"Huawei Technologies Co., LTD.","member_since":"2015-06-23","renewal_date":"2026-10-01","description":{"long":"Huawei is a leading global information and communications technology (ICT) solutions provider. Driven by a commitment to sound operations, ongoing innovation, and open collaboration, we have established a competitive ICT portfolio of end-to-end solutions in telecom and enterprise networks, devices, and cloud technology and services. Our ICT solutions, products, and services are used in more than 170 countries and regions, serving over one-third of the world\\'s population. With more than 180,000 employees, Huawei is committed to enabling the future information society, and building a Better Connected World."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1380-web.png"},"website":null,"levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"},{"document_id":"efcdef5b284754c43de2","description":"Strategic Member","level":"WGSD","working_group":"orc"},{"document_id":"f348c2873ca8ed8e9eca","description":"Strategic Member","level":"WGSD","working_group":"oniro"}],"is_active_member":true},{"organization_id":1382,"name":"Software Institute, Università della Svizzera italiana","member_since":"2019-11-26","renewal_date":"2026-12-01","description":{"long":"At the Software Institute, we discover, design, and develop new ideas that ease the conception of modern software systems. Our research is rooted both in sound theoretical models as well as practical, real-life questions that impact modern society."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1382-web.png"},"website":"https://si.usi.ch","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1383,"name":"Bird Software Solutions Ltd","member_since":"2019-11-27","renewal_date":"2026-12-01","description":{"long":"BIRD Software Solutions Ltd provides solutions and consultancy to support the use of the Banks Integrated Reporting Directory (BIRD) project which is managed by the European Central Bank. (https://www.ecb.europa.eu/stats/ecb_statistics/co-operation_and_standards/reporting/html/bird_dedicated.en.html ) "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1383-web.png"},"website":"https://www.birdsoftwaresolutions.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1384,"name":"CANARY LABS INC.","member_since":"2019-12-03","renewal_date":"2026-12-01","description":{"long":"Considering most operations have thousands (if not hundreds of thousands) of data points, how you collect and store your data is vitally important to your success.\\r\\n\\r\\nAt Canary, we believe making your data easy to store and recall makes you more successful. We\\'ve spent over 20 years building a time series database that sets the standard in any industry.\\r\\n\\r\\nThe Canary System allows you to:
    \\r\\n\\r\\nCollect and store billions of data values.
    \\r\\nSpend less time on database management.
    \\r\\nNever worry about performance or losing your data.
    \\r\\n\\r\\nPaired with the MQTT Sparkplug B protocol, you can easily scale your organization from just few tags to millions without spending months of man hours."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1384-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1387,"name":"DENSO AUTOMOTIVE Deutschland GmbH","member_since":"2019-12-16","renewal_date":"2027-01-01","description":{"long":"DENSO AUTOMOTIVE Deutschland GmbH is a subsidiary of DENSO Corporation which is a global automotive supplier company."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1387-web.png"},"website":"https://www.denso.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1390,"name":"OSB Alliance- Bundesverband für digitale Souveränität e.V.","member_since":"2020-01-01","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1391,"name":"TmaxSoft Co., Ltd","member_since":"2020-02-01","renewal_date":"2027-02-01","description":{"long":"TmaxSoft was founded on the principle that there is always a better way. Nothing will stop us from creating better solutions that improve your business in ways that other companies cant. Or wont. A global software innovator focused on cloud, infrastructure and legacy modernization, we give you the freedom to take control of your technology. Our complete stack of software solutions help you efficiently manage and fully leverage your critical data. This provides global IT customers with software-defined mainframe rehosting, middleware and RDBMS technology that enables IT to actively and effectively contribute to achieving business objectives. With our remarkable technology, fresh perspective, collaborative spirit, and unusual clarity and transparency, youll finally have the choice you deserve. Along with freedom from status quo technology, more opportunities and faster ways to innovate, reduced risk of change, greater cost savings, and a better customer experience. \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1391-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1397,"name":"Kingdee Apusic Cloud Computing Co.,Ltd","member_since":"2020-02-15","renewal_date":"2027-02-01","description":{"long":"Kingdee Apusic cloud computing Co., Ltd. was founded in 2000, formerly known as Kingdee middleware Co., Ltd., which is a subsidiary of Kingdee group and a member of China Electronics Technology Group Taiji Co., Ltd. It is a key software enterprise in the national planning and layout and a leading cloud service provider of digital government, basic software service provider, and public financial management software service provider of China."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1397-web.png"},"website":"https://www.apusic.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1399,"name":"NEC Corporation","member_since":"2021-10-14","renewal_date":"2026-08-01","description":{"long":"NEC provides products for business, ranging from terminals to network and computer equipment, software products and service platforms, as well as integrated platforms based on them. We deliver labor-saving and efficient platforms for customers, while at the same time creating new value such as IoT platforms based on ICT as we contribute to the expansion of solutions for society."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1399-web.png"},"website":"https://www.nec.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1401,"name":"Primeton Information Technologies, Inc","member_since":"2020-02-18","renewal_date":"2027-03-01","description":{"long":"Primeton was established on March 36, 2003 and changed from a limited liability company to a joint stock company in 2010. The company has obtained a number of national honor certifications, such as National Enterprise Technology Center, Postdoctoral Research Station, and continuously passed the International Software Capability Maturity Model Integration (CMMI) Level 5 Certification and ISO9001 Quality Management System Certification. It has mastered 41 key and major core technologies and a number of reserve technologies in the field of software foundation platforms, 27 invention patents and172 software copyrights. The company participated in two important SOA international technical specifications of SCA / SDO and 11 national technical standards Formulation.\\r\\nPrimeton is a professional software foundation platform provider. It provides independent, controllable, safe and reliable software foundation platforms and application software development services for large and medium-sized users in the financial, government, energy, telecommunications, manufacturing and other industries.\\r\\nSince its establishment, the company has continued to cultivate the field of software foundation platforms. After more than ten years of technology and experience, it has established a \\\"standard product + platform customization + application development\\\" business model, which includes the sales and maintaining service of standard software products of the software foundation platform, platform customization and application development services.\\r\\nPrimeton has been committed to the construction of independent research and development and innovation capabilities of the core technology of the software foundation platform. It has created a component-based technology platform and core technology combination, and formed a systematic technology research and development capability, the platformized capability of product development and comprehensive project implementation methodology. Based on core technologies and innovation capabilities, Primeton provides customers with software products and technical services, helping customers flexibly and quickly respond to complex and changing business scenarios and successfully achieve business transformation under new generation information technologies such as cloud computing and big data.\\r\\nAfter more than ten years of focused development, Primeton enjoys high brand awareness in the field of software foundation platforms. In 2018, there were 120 Chinese companies in the Fortune Global 500, 44 of which chose Primeton Informations software platform products or technical solutions. The technical performance, maturity and safety and reliability of the company\\'s products and technical solutions have been verified in thousands of large-scale and key projects in national economic key areas such as finance, government affairs, energy, telecommunications, and manufacturing. Primeton has a China Registration and Clearing Corporation , Shanghai Gold Exchange, China Mobile, General Administration of Customs and other large and medium-sized customers in the industry are all Primetons regular customers. Primeton has gradually changed the absolute dominant position of international brands in the domestic software infrastructure platform market."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1401-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Enterprise Member","level":"WGDSA","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1405,"name":"Barcelona Supercomputing Center (BSC)","member_since":"2020-03-05","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1405-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1409,"name":"Futurewei Technologies, Inc.","member_since":"2020-03-06","renewal_date":"2026-10-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1409-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f348c2873ca8ed8e9eca","description":"Silver Member","level":"WGHLP","working_group":"oniro"}],"is_active_member":true},{"organization_id":1423,"name":"University of Bologna","member_since":"2021-10-14","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1423-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1427,"name":"openKONSEQUENZ eG","member_since":"2020-03-09","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1427-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1428,"name":"Alibaba Cloud","member_since":"2020-05-01","renewal_date":"2027-05-01","description":{"long":"As a business unit of Alibaba Group (NYSE: BABA), Alibaba Cloud provides a comprehensive suite of global cloud computing services to power both our international customers online businesses and Alibaba Groups own e-commerce ecosystem. In January 2017, Alibaba Cloud became the official Cloud Services Partner of the International Olympic Committee.\\r\\nBy harnessing, and improving on, the latest cloud technology and security systems, we tirelessly work towards our vision - to make it easier for you to do business anywhere, with anyone in the world."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1428-web.png"},"website":"https://www.alibabacloud.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"},{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1434,"name":"Polytechnique Montreal","member_since":"2020-03-27","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1434-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1436,"name":"ETH Zurich","member_since":"2020-04-02","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1436-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1437,"name":"Broadcom","member_since":"2008-02-28","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1437-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"","level":"WGSM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1441,"name":"Topio Networks","member_since":"2020-04-28","renewal_date":"2027-05-01","description":{"long":"Topio Networks, an industry research platform, \\r\\naccelerates markets and businesses by providing \\r\\ndetailed information about use cases, verticals \\r\\nand industries. \\r\\n\\r\\nTopio Networks offers detailed data insights and natural language analysis about the shape, structure and sizing of the thousands of use cases, verticals and \\r\\ntechnologies that are the building blocks of the fourth \\r\\nindustrial revolution. Our data is constantly fed by \\r\\nthe daily insights generated by our taxonomy driven, \\r\\nhuman curated AI Platform. \\r\\n\\r\\nThe Topio Networks Market Intelligence Center provides free access to our industry research with detailed data about market sizing, innovations, funding and marketing activities for each specific use cases, industries and emerging technologies. \\r\\n\\r\\nIn addition, Topio Networks offers acceleration \\r\\nservices to businesses by providing the content \\r\\nnecessary to develop their go to market strategies, by \\r\\ntracking the company content and mapping it to the \\r\\nbest practices of the industry and providing market \\r\\naccess through events and lead generation.\\r\\nTo learn more about how Topio Networks applies \\r\\nAI and Natural Language Processing to create \\r\\ncomprehensive research about thousands of use \\r\\ncases,"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1441-web.png"},"website":"https://www.topionetworks.com","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1442,"name":"Chevron Technical Center","member_since":"2020-04-29","renewal_date":"2027-05-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1442-web.png"},"website":"https://www.chevron.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1443,"name":"Open Source Robotics Foundation","member_since":"2020-05-06","renewal_date":"2027-05-01","description":{"long":"We offer robotics R&D, consulting, custom engineering, and application development services to industry and government. We work with companies large and small and public agencies around the world. Whether you want to learn more about Gazebo, need to streamline your ROS-based product development, or are looking for a partner for your next R&D program, we\\'re here to help. The unifying theme of our team and our work is openness. We use and we build open systems. To the greatest extent possible, we freely distribute our work product, whether software, hardware, or documentation, under an open source license."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1443-web.png"},"website":"https://www.openrobotics.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1451,"name":"Institut für angewandte Systemtechnik Bremen Gmbh","member_since":"2020-06-18","renewal_date":"2026-06-01","description":{"long":"What is ATB?
    \\r\\nATB is an application oriented research institute founded jointly by the Free Hanseatic City of Bremen and several leading industrial enterprises in Bremen area in 1991.\\r\\n

    \\r\\nATB is a part of the long-term strategy of the Free Hanseatic City of Bremen to sustain economy in northern Germany and, particularly, in Bremen by strengthening innovation potentials of industrial enterprises and other organisations.\\r\\n

    \\r\\nATB is a highly innovative and efficient technology centre providing system technology related services to a wide spectrum of enterprises and organisations, thereby increasing their ability to remain competitive. ATB has developed into a dynamically expanding research institute operating successfully on the national, European and world-wide market and offering to partners a high level of expertise in several technological domains.\\r\\n

    \\r\\nWhat does ATB offer?
    \\r\\nATB offers\\r\\n

      \\r\\n
    • services in process/product innovation activities based on advanced Information and Communication Technology solutions
    • \\r\\n
    • flexibility of a dynamic, performance and application oriented research institute
    • \\r\\n
    • remarkable competencies in both
    • \\r\\n
        \\r\\n
      • technical and research domains
      • \\r\\n
      • management of complex technical projects
      • \\r\\n
      \\r\\n
    • High expertise in several domains based on effective team-building of staff members with long-term experience and agile young researchers
    • \\r\\n
    \\r\\nThe basis for all projects is a cooperative partnership with clients, allowing for a collaborative and effective approach to achieve the clients innovation targets.\\r\\n
    \\r\\nATB provides its services within:\\r\\n
      \\r\\n
    • Application oriented research projects supported by regional, national, European and other international funding schemes
    • \\r\\n
    • Direct research projects with clients
    • \\r\\n
    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1451-web.png"},"website":"https://www.atb-bremen.de","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1453,"name":"University of Oslo, Dept of Informatics","member_since":"2020-07-07","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1458,"name":"Beijing Tongtech Co., Ltd","member_since":"2020-07-21","renewal_date":"2026-08-01","description":{"long":"Beijing Tongtech Co., Ltd (Tongtech) is an industry leading infrastructure software and IT solutions provider. With its state of the art technology and products, Tongtech provides its customers with a complete family of application infrastructure products ranging from middleware, information security solutions to intelligent transportation system (ITS) solutions. Over the years, Tongtechs products and solutions has helped its customers leverage the power of internet to upgrade their businesses in a safe and effective manner.\\r\\n\\r\\nTongtech has been named as one of the \\\"National Key Software Enterprises\\\" for 12 consecutive years, and was granted AAA credit ratings by the Ministry of Commerce as well as the State-owned Asset Supervision and Administration Commission of the State Council (SASAC). In the field of technology, Tongtech is the core member of the Java Community Process Program (JCP) and the National Information Technology Standardization Committee, and has participated in developing industry standards for JavaEE, SOA/middleware, IEC smart city and other international and domestic standards organizations. Our company is also a research center for Major National Science and Technology Programs and has won the \\\"National Science and Technology Progress Award\\\" granted by the State Council for our achievements and efforts.\\r\\n\\r\\nAs a pioneer in the middleware software industry, our software products and solutions are widely used in all kinds of industries in China, with more than 2,000 enterprise users spreading across industries such as finance, communication, government, energy, and transportation. Tongtech also enjoyed good partnership with 500 partners."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1458-web.png"},"website":"https://www.tongtech.com/sy.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1465,"name":"RIOS Lab","member_since":"2020-09-18","renewal_date":"2026-10-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1465-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1469,"name":"Atlanta Java Users Group, Inc","member_since":"2020-10-05","renewal_date":"2026-10-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1469-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1473,"name":"Circuitsutra Technologies Pvt Ltd","member_since":"2020-10-19","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1473-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1474,"name":"Apex.AI, Inc","member_since":"2020-10-19","renewal_date":"2026-11-01","description":{"long":"Apex.AI was founded in 2017 in Palo Alto to build robust, reliable, safe, secure, and certified software for autonomous mobility systems. \\r\\n
    \\r\\n\\r\\nCore products:\\r\\n
    \\r\\n1. Apex.Grace is a runtime software environment, which is built on ROS 2 (Robot Operating System) and provides a production-grade safety-certified realtime framework for developing safe and secure applications. \\r\\n
    \\r\\n2. Apex.Ida is a highly optimized communication middleware based on Eclipse iceoryx and Eclipse Cyclone DDS"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1474-web.png"},"website":"https://www.apex.ai/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1476,"name":"Data In Motion Consulting GmbH","member_since":"2020-11-10","renewal_date":"2026-11-01","description":{"long":"

    Founded in 2010, in Jena (Thuringia, Germany), Data In Motion Consulting GmbH provides a strong consolidated experience in the fields of Modeling, Software Engineering, Architecture and Consulting.

    \\r\\n

    We assist our customers in the development of their projects, guiding them trough the whole process, while providing them with the required strategies and tools to be able to \\\"walk on their own\\\" in the future.

    \\r\\n

    Our skill set goes from the more technical expertise in model-driven software development and architecture, data analysis and independent R&D, to more managerial experience in project and product management, and moderation of the whole business process.

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1476-web.png"},"website":"https://www.datainmotion.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1480,"name":"AICAS GmbH","member_since":"2020-11-30","renewal_date":"2027-01-01","description":{"long":"aicas embraces the mission to bring intelligence to devices and unlock realtime data. The international high-tech company creates embedded IoT and edge-to-cloud solutions.\n\nAcross the globe, aicas connects over 25 million devices and vehicles to the cloud, simplifying access and control of edge devices and their data. Large industrial companies and leading automotive manufacturers use aicas EdgeSuite and JamaicaVM to master their digital transformation and open up new business models.\n\nCreating, deploying and operating edge-to-cloud solutions: aicas makes it happen. \nFast. Simple. Reliable."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1480-web.png"},"website":"https://www.aicas.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"}],"is_active_member":true},{"organization_id":1481,"name":"Beijing Thunisoft Information Technology Co., Ltd","member_since":"2020-11-30","renewal_date":"2026-12-01","description":{"long":"Thunisoft adheres to the enterprise spirit of \\\"Self-discipline and Social Commitment\\\", adheres to the values of honesty and integrity, takes \\\"Continuous innovation,to serve for customers\\' success\\\" as its mission, focuses on software and information services, providing customers with a full range of solutions and services for their informatization business, and is your trusted expert in intelligent information services."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1481-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1482,"name":"Makewave AB","member_since":"2020-12-09","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1482-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"}],"is_active_member":true},{"organization_id":1485,"name":"Garden State Java User Group (GSJUG)","member_since":"2021-01-06","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1485-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Guest Member","level":"WGSAP","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1486,"name":"The Johns Hopkins University","member_since":"2021-01-11","renewal_date":"2026-11-01","description":{"long":"Founded in 1876 as the nation’s first research university, Johns Hopkins has been advancing knowledge and bringing discoveries to the world for nearly 150 years."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1486-web.png"},"website":"https://www.jhu.edu/about/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1487,"name":"Shandong Cvicse Middleware Co.,Ltd","member_since":"2021-01-11","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1487-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Enterprise Member","level":"WGDSA","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1488,"name":"SignalFire Telemetry ","member_since":"2021-01-18","renewal_date":"2027-01-01","description":{"long":"The SignalFire wireless platform is offered with 900Mhz or with LTE-M1 for flexibility and cost effectiveness. The architecture provides for long-range wireless networks designed for remote monitoring and control in challenging outdoor environments. The nodes are integrated with a variety of sensors to work with level, pressure, temperature and flow meters, as well as offering critical asset control of valves, pumps, fans, heaters and an array of other devices.\\r\\n\\r\\nThe SignalFire wireless system has been deployed in thousands of installations in oil & gas fields and pipelines, petrochemical processing plants, crop and irrigation monitoring systems, transportation monitoring systems, and municipal infrastructure monitoring and control systems, as well as a variety of other applications.\\r\\n\\r\\nOur nodes can provide both communications and power to your sensors, making your application truly wireless. A wide range of sensor types are compatible, including 4-20 mA, 1.5V, Modbus, Hart, Digital I/O and other analog and digital interfaces.\\r\\n\\r\\nTo find out more, contact SignalFire and tell us about your toughest monitoring and control challenge."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1488-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Participant Member","level":"WGAPS","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1489,"name":"Netherlands Organisation for applied scientific research TNO","member_since":"2021-01-21","renewal_date":"2027-02-01","description":{"long":"

    About TNO

    \\r\\n

    The Netherlands Organization for Applied Scientific Research (TNO) is an independent research organization. We connect people and knowledge to create innovations that boost the sustainable competitive strength of industry and well-being of society. Now and in the future. This is our mission and it is what drives us, the over 3.000 professionals at TNO, in our work every day. We work in collaboration with partners and focus on transitions or changes in nine social themes that we have identified together with our stakeholders.

    \\r\\n\\r\\n

    Information & Communication Technology: \\'Interpreting and accelerating digital transformation\\'

    \\r\\n

    TNOs Information & Communication Technology unit aims to assist its clients, partners and other TNO units through complex digital transformations by leveraging its know-how in ICT, policy and business models. In concrete terms, we work in three main areas: data-driven innovations, robust networks, and integrated computer systems. We operate in domains such as ICT, telecoms, defence & security, high-tech industry, the energy sector, mobility and logistics. \\r\\n

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1489-web.png"},"website":"https://www.tno.nl/en/focus-areas/information-communication-technology/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1491,"name":"CSEM SA","member_since":"2021-01-28","renewal_date":"2027-02-01","description":{"long":"We are a public-private, non-profit technology innovation center. Dedicated to transforming brilliant ideas into industrial reality. With the support of the Swiss Federal government our mission is to secure our nation’s status as a global tech and innovation leader."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1491-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1492,"name":"The University of Sheffield","member_since":"2021-02-02","renewal_date":"2027-02-01","description":{"long":"The University of Sheffield Advanced Manufacturing Research Centre (AMRC) is a network of world-leading research and innovation centres working with manufacturing companies of any size from around the globe.\\r\\n\\r\\nWe specialise in carrying out world-leading research into advanced machining, manufacturing and materials, which is of practical use to industry.\\r\\nWe transform industrial and economic performance by making step changes in productivity, increasing competitiveness, developing new products and processes and training new talent and skills.\\r\\n\\r\\nOur 125-plus industrial partners range from global giants like Boeing, Rolls-Royce, BAE Systems and Airbus to small companies. Businesses can work with us on a one-off project, or join us as a member for long-term collaboration.\\r\\nOur operations have grown significantly since we were founded in 2001 and in 2003 we became the anchor tenant on the Advanced Manufacturing Park at Catcliffe, South Yorkshire.\\r\\n\\r\\nThe AMRC now employs over 500 highly qualified researchers and engineers from around the globe, on the Advanced Manufacturing Park and Sheffield Business Park in South Yorkshire, as well as in Broughton and Preston."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1492-web.png"},"website":"https://www.amrc.co.uk","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Guest Member","level":"WGSAP","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1494,"name":"Adobe","member_since":"2021-02-05","renewal_date":"2027-02-01","description":{"long":"Adobe"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1494-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"68db2919ffe553250ae8","description":"Participant Member","level":"WGAPS","working_group":"osgi"}],"is_active_member":true},{"organization_id":1501,"name":"Opto 22","member_since":"2021-04-08","renewal_date":"2027-01-01","description":{"long":"For over 45 years, OEMs, machine builders, system integrators, and IT and operations personnel have looked to us for reliable products that deliver cutting-edge innovation at an affordable price.\\r\\n\\r\\nToday, we design and manufacture industrial control and IIoT products, like groov EPIC and groov RIO, that bridge the gap between IT and OT, following a core philosophy of open, standards-based technology.\\r\\n\\r\\nOpto 22 products are deployed worldwide in industrial automation, process control, building automation, industrial refrigeration, remote monitoring, and data acquisition applications through our global network of distributors and system integrators.\\r\\n\\r\\nOpto 22\\'s groov family of industrial edge controllers and I/O is designed from the ground up with integrated control, connectivity, and security tools to help you connect automation, enterprise, and cloud data.\\r\\n\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1501-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1503,"name":"Flow Software, Inc.","member_since":"2021-04-22","renewal_date":"2027-05-01","description":{"long":"The Flow Information Platform simplifies the creation and sharing of operational and strategic decision support information across your organization.\\r\\n\\r\\nCombine and transform data from multiple sources into a single namespace representing your \\\"single version of the truth\\\". Share this truth with people via configurable dashboards or with systems via configurable integrations.\\r\\n\\r\\nFlow is an \\\"ETL for OT\\\", a \\\"DataOps\\\" platform, that ingests and transforms complex data into KPIs, making it accessible when it is needed the most. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1503-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1504,"name":"Interuniversitair Micro-Electronica Centrum vzm (IMEC)","member_since":"2021-05-11","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1504-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"},{"document_id":"68db2919ffe553250ae8","description":"Guest Member","level":"WGSAP","working_group":"osgi"},{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1505,"name":"The Apache Software Foundation","member_since":"2021-05-11","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1505-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1506,"name":"Beijing Baolande Software Corporation","member_since":"2021-05-14","renewal_date":"2027-05-01","description":{"long":"Beijing Baolande Software Corporation founded in 2008, is a high-tech software enterprise focusing on basic software development and promotion."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1506-web.png"},"website":"https://www.bessystem.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1512,"name":"Fondazione LINKS","member_since":"2021-07-20","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1512-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1513,"name":"Trialog ","member_since":"2021-08-10","renewal_date":"2026-08-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1513-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1515,"name":"NOI Techpark","member_since":"2021-08-26","renewal_date":"2026-09-01","description":{"long":"We are NOI. South Tyrol's innovation district.\nInnovation, research, development. 1.000+ entrepreneurs, researchers, start-ups and students are working at NOI for an ecological and economic conversion of society. At NOI, research is practice-oriented. The needs of companies give rise to scientific work. \nAt NOI, we focus on four technology fields: Green, Food, Digital, Automotive & Automation. We are rooted in South Tyrol and in South Tyrolean society. At the same time, we work with an international slant. \nFor R&D projects we offer services and knowhow through our dataspaces platform Open Data Hub https://opendatahub.com and the Free Software Lab https://freesoftwarelab.noi.bz.it "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1515-web.png"},"website":"https://noi.bz.it/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Supporter Member","level":"WGSM","working_group":"dataspace"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"f348c2873ca8ed8e9eca","description":"Silver Member","level":"WGHLP","working_group":"oniro"}],"is_active_member":true},{"organization_id":1519,"name":"European Space Agency","member_since":"2021-09-20","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1519-web.png"},"website":null,"levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[],"is_active_member":true},{"organization_id":1520,"name":"Volkswagen Aktiengesellschaft","member_since":"2021-10-04","renewal_date":"2026-06-01","description":{"long":"The Volkswagen Group comprises ten brands from five European countries: Volkswagen, Volkswagen Commercial Vehicles, ŠKODA, SEAT, CUPRA, Audi, Lamborghini, Bentley, Porsche and Ducati. On our way to becoming a sustainable mobility provider with a role model function in the areas of environment, safety and integrity, Volkswagen Group Innovation rely on a cross-brand and efficient research network. This network connects experts, enables partnership-based cooperation at eye level, creates an innovative working environment and bundles activities in order to increase synergies and efficiencies across the Volkswagen group"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1520-web.png"},"website":"https://www.volkswagen.de/de.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"aea0514f5cc2d0407ffd","description":"Driver Member","level":"WGPAE","working_group":"openpass"}],"is_active_member":true},{"organization_id":1521,"name":"Industrial Digital Twin Association","member_since":"2021-10-06","renewal_date":"2026-10-01","description":{"long":"The IDTA is the first point of contact for the standardised Digital Twin and offers all industrial organisations a platform for participation. The aim is to establish the Digital Twin for components, machines, plants and entire factories as an open source technology and to develop it further together with industry.\nThe core technology for the implementation is the Asset Administration Shell (AAS), that enables quick and easy access to data over the entire life cycle thanks to standardised software structure, interfaces and semantics using current security mechanisms. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1521-web.png"},"website":"https://industrialdigitaltwin.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1524,"name":"University of Saskatchewan","member_since":"2021-10-15","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1524-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1525,"name":"University of California, Santa Barbara","member_since":"2021-10-15","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1530,"name":"Institute of Software Chinese Academy of Sciences","member_since":"2021-10-15","renewal_date":"2026-08-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1530-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1532,"name":"Asiainfo Technologies limited","member_since":"2024-04-15","renewal_date":"2026-11-01","description":{"long":"Started in 1993, AsiaInfo Technologies Limited is a leading provider of information technology products and services and a pioneering provider of full-stack digital intelligence capabilities. AsiaInfo provides end-to-end and full-link digital intelligence services for hundreds of industries based on its full-stack digital intelligence capabilities such as consulting and planning, product R&D, product delivery, system integration, data operation, intelligent decision-making, customer services. \n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1532-web.png"},"website":"https://www.asiainfo.com/en_us/index.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1540,"name":"Amadeus S.A.S.","member_since":"2021-11-23","renewal_date":"2026-11-01","description":{"long":"Travel powers progress. Amadeus powers travel. Amadeus solutions connect travelers to the journeys they want through travel agents, search engines, tour operators, airlines, airports, hotels, cars and railways.\\r\\nWe have developed our technology in partnership with the travel industry for over 30 years. We combine a deep understanding of how people travel with the ability to design and deliver the most complex, trusted, critical systems our customers need. In 2019, we helped connect over 1.9 billion people to local travel providers in over 190 countries. We help connect over 1.6 billion people a year to local travel providers in over 190 countries.\\r\\n

    We are one company, with a global mindset and a local presence wherever our customers need us.

    \\r\\n

    Our purpose is to shape the future of travel. We are passionate in our pursuit of better technology that makes better journeys.

    \\r\\nAmadeus is an IBEX 35 company, listed on the Spanish Stock Exchange under AMS.MC. The company has also been recognized by the Dow Jones Sustainability Index for the last ten years.\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1540-web.png"},"website":"https://amadeus.com/en","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1541,"name":"Scheidt & Bachmann System Technik GmbH","member_since":"2021-11-29","renewal_date":"2026-12-01","description":{"long":"

    System manufacturer for software and hardware systems for control and safety technology for the railway domain. Innovative solutions for control and administration of rail-bound traffic.

    \\r\\n

    The developers at the site in Kiel-Melsdorf complement the SIL 4 signalling-department of Mönchengladbach, Germany, with the ZSB2000 interlocking system and the BUES2000 level-crossing. This especially includes complex traffic-control-systems for large international inter-city-railways and metro-customers (on basis of the control centers of the DB Netz AG, the product Travis and the train detection system ZNP801D), an operation and interlocking simulation (\\\"Betriebs- und Stellwerkssimulation\\\", BEST), next to a modern tooling ecosystem for supporting planning, configuration, development and quality assurance.

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1541-web.png"},"website":"https://www.scheidt-bachmann.de/de/signalling-systems/home","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1542,"name":"Nokia","member_since":"2021-11-29","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1542-web.jpg"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Strategic Member","level":"WGSD","working_group":"orc"}],"is_active_member":true},{"organization_id":1543,"name":"AURA","member_since":"2021-12-16","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1544,"name":"Data Intelligence Offensive (DIO)","member_since":"2021-12-21","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1545,"name":"Frontgrade Gaisler","member_since":"2021-12-21","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1545-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1547,"name":"Array","member_since":"2022-01-05","renewal_date":"2027-01-01","description":{"long":"Array is a law firm dedicated to IT matters, with a specific focus on Free and Open Source Software and other field of open technology, data, science and society. Founded by Carlo Piana, a renown lawyer and advocate in the FOSS space since early 2000's, it includes high-quality experts in the field and mentioned by the Who's Who Legal for IT in Italy. The members of Array have a deep knowledge of the legal and technical aspects of the IT world. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1547-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"f348c2873ca8ed8e9eca","description":"Guest Member","level":"WGSAP","working_group":"oniro"}],"is_active_member":true},{"organization_id":1550,"name":"Accenture GmbH","member_since":"2022-02-04","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1550-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1551,"name":"Capgemini","member_since":"2022-02-15","renewal_date":"2027-02-01","description":{"long":"Capgemini is a global leader in partnering with companies to transform and manage their business by harnessing the power of technology. The Group is guided everyday by its purpose of unleashing human energy through technology for an inclusive and sustainable future. It is a responsible and diverse organization of over 325,000 team members more than 50 countries. With its deep industry expertise, Capgemini is trusted by its clients to address the entire breadth of their business needs, from strategy and design to operations, fueled by the innovative world of cloud, data, AI, connectivity, software, digital engineering and platforms. The Group reported in 2021 global revenues of €18 billion."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1551-web.jpg"},"website":"https://www.capgemini.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f348c2873ca8ed8e9eca","description":"Supporting Member","level":"WGSM","working_group":"oniro"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1553,"name":"ZF Friedrichshafen AG","member_since":"2022-02-25","renewal_date":"2027-03-01","description":{"long":" ZF is a global technology company supplying systems for passenger cars, commercial vehicles and industrial technology, enabling the next generation of mobility. ZF allows vehicles to see, think and act. In the four technology domains of Vehicle Motion Control, Integrated Safety, Automated Driving, and Electric Mobility, ZF offers comprehensive product and software solutions for established vehicle manufacturers and newly emerging transport and mobility service providers. ZF electrifies a wide range of vehicle types. With its products, the company contributes to reducing emissions, protecting the climate and enhancing safe mobility."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1553-web.png"},"website":"https://www.zf.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1554,"name":"AUMOVIO Germany GmbH","member_since":"2022-02-28","renewal_date":"2027-03-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1554-web.png"},"website":"https://www.aumovio.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1555,"name":"Reycom AG, a Swiss corporation","member_since":"2022-02-28","renewal_date":"2027-03-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1555-web.png"},"website":"https://www.reycom.swiss/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1559,"name":"ZettaScale Technology SARL","member_since":"2022-03-03","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1559-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Leader Member","level":"WGLM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1561,"name":"ESOP- Empresas SW OS Portuguesas","member_since":"2022-03-25","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1566,"name":"Sustainable Digital Infrastructure Alliance","member_since":"2022-05-11","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1568,"name":"ETAS GmbH","member_since":"2022-05-25","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1568-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1570,"name":"CARIAD SE","member_since":"2022-05-31","renewal_date":"2026-06-01","description":{"long":"CARIAD is an automotive software company in the Volkswagen Group that develops a leading tech stack for the automotive industry with the mission to make the automotive experience safer, more sustainable and more comfortable in a new way – for everyone, everywhere. \nCARIAD builds a uniform software platform for all brands of Volkswagen Group, which includes a unified and scalable architecture, an operating system and automotive cloud. CARIAD’s Headquarter is located in Germany, and co-operates with international Volkswagen Group teams in the US and China. \n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1570-web.png"},"website":"https://cariad.technology/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1571,"name":"Omnifish OU","member_since":"2022-06-24","renewal_date":"2026-07-01","description":{"long":"At OmniFish, we specialize in providing professional services for Jakarta EE technologies. Our seasoned team of experts excels in Java application development and Java middleware production support. As dedicated contributors to the Eclipse GlassFish project and active members of the Jakarta EE Working Group, we are committed to modernizing the GlassFish server and contributing to Jakarta EE specifications. Customer success is our top priority. We work closely with our clients and partners to help them craft exceptional applications and services, ensuring our customers a safe journey filled with joy. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1571-web.png"},"website":"https://omnifish.ee","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1572,"name":"Elektrobit Automotive GmbH","member_since":"2022-07-05","renewal_date":"2026-07-01","description":{"long":"Elektrobit is an award-winning and visionary global vendor of embedded and connected software products and services for the automotive industry. A leader in automotive software with over 35 years serving the industry, Elektrobit's software powers over five billion devices in more than 600 million vehicles and offers flexible, innovative solutions for car infrastructure software, connectivity & security, automated driving and related tools, and user experience. Elektrobit is a wholly-owned, independently-operated subsidiary of Continental."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1572-web.png"},"website":"https://www.elektrobit.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1575,"name":"Dipartimento di Elettronica, Informazione e Bioingegneria - Politecnico di Milano","member_since":"2022-07-28","renewal_date":"2026-08-01","description":{"long":"The Dipartimento di Elettronica, Informazione e Bioingengeria of the Politecnico di Milano is one of the largest European ICT departments. With nearly 1000 members, researchers, collaborators, PhD students, and technical and administrative staff, the Department is a vital institution capable of promoting education, fundamental and applied research, and technology transfer to companies. The six department sections bring together consolidated competencies in systems and control, computer science and engineering, electronics, telecommunications, bioengineering, and electrical engineering."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1575-web.png"},"website":"https://www.deib.polimi.it/ita/home","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"f348c2873ca8ed8e9eca","description":"Guest Member","level":"WGSAP","working_group":"oniro"}],"is_active_member":true},{"organization_id":1579,"name":"Shenzhen Ping An Communication Technology Co.,Ltd","member_since":"2022-08-11","renewal_date":"2026-08-01","description":{"long":"We are a technology solution expert of Ping An group\n\nPractice the corporate mission of \"science and technology enable finance and science and technology drive ecology\"\n\nEmpowering the group's financial services, medical and health services, automobile services, and smart city ecosystem construction\n\nCommitted to becoming an international leading technology company"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1579-web.png"},"website":"https://tech.pingan.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1580,"name":"Bloomberg L.P.","member_since":"2022-08-23","renewal_date":"2026-09-01","description":{"long":"Bloomberg is a global leader in business and financial information, delivering trusted data, news, and insights that bring transparency, efficiency, and fairness to markets. The company helps connect influential communities across the global financial ecosystem via reliable technology solutions that enable our customers to make more informed decisions and foster better collaboration. Our 7,000+ engineers, developers, data scientists and technologists are the ones who make this happen, creating and advancing solutions and systems that solve complex, real-world problems for customers across the global capital markets."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1580-web.png"},"website":"https://www.TechAtBloomberg.com/opensource","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Enterprise Member","level":"WGDSA","working_group":"adoptium"}],"is_active_member":true},{"organization_id":1582,"name":"FUJIFILM Italia S.p.A","member_since":"2022-09-02","renewal_date":"2026-09-01","description":{"long":"FUJIFILM Italia - Medical Informatics Research & Development Unit\nMain activities of the Unit are Technological Research in the IT field, Design and Development of Software Products and Applications, Consulting on Digital Solutions for the Healthcare."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1582-web.png"},"website":"https://www.fujifilm.com/it/en/about/us/offices/fujifilm-italia-unita-operativa-locale-di-bolzano","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1584,"name":"Harvey Mudd College","member_since":"2022-09-09","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1584-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1587,"name":"Oklahoma State University","member_since":"2022-09-13","renewal_date":"2026-09-01","description":{"long":"Oklahoma State University is a public land-grant research university in Stillwater, Oklahoma, United States. The university was established in 1890 under the legislation of the Morrill Act."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1587-web.png"},"website":"https://go.okstate.edu/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1588,"name":"PlanV GmbH","member_since":"2022-09-16","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1588-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1589,"name":"T-Systems International GmbH","member_since":"2022-09-20","renewal_date":"2026-09-01","description":{"long":"With locations in more than 20 countries and over 27,000 employees (December 31, 2022), as well as annual revenues of around EUR 4.0 billion (2022), T-Systems is one of the leading providers of digital services in Europe. The Deutsche Telekom subsidiary is headquartered in Germany and has a presence in Europe as well as in selected core markets and strategic production locations. T-Systems offers integrated end-to-end IT solutions, driving the digital transformation of companies in all industries and the public sector. T-Systems’ focus industries are automotive, the public sector, healthcare and transport. For these areas, T-Systems develops industry-specific solutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1589-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1591,"name":"Universidad de Cantabria","member_since":"2022-09-23","renewal_date":"2026-08-01","description":{"long":"

    The University of Cantabria (UC) offers official university study courses in the self-governed region of Cantabria (Spain).

    \n\n

    The Software Engineering and Real-Time Group (Ingeniería del Software y Tiempo Real, ISTR) has kept a continuous research activity in the theory and application of Software Engineering to Distributed Embedded Real-Time Systems, Model-Driven Engineering, Databases and Business Intelligence, and Security in Information Systems. The group also actively participates in the development of standards: Real-time POSIX operating systems, the UML-MARTE profile of OMG, and the standardization process of the Ada language.

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1591-web.jpg"},"website":"https://web.unican.es/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1592,"name":"Google LLC","member_since":"2022-10-12","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1592-web.png"},"website":"","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"},{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1594,"name":"Quantyss","member_since":"2022-10-18","renewal_date":"2026-10-01","description":{"long":"QUANTYSS is a startup company created to share senior expertise to innovative entrepreneurs of SMEs, startups and midcaps, in the field of technology. We provide specialized insight and relevant industry expertise to help them take their business further.\nWe are actively driving, together with Eclipse members, the Edge Computing Working Group of the French Embedded France Association. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1594-web.png"},"website":"https://quantyss.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1595,"name":"Rivos Inc","member_since":"2022-10-18","renewal_date":"2026-10-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1595-web.png"},"website":"https://www.rivosinc.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"}],"is_active_member":true},{"organization_id":1597,"name":"Kentyou","member_since":"2022-10-25","renewal_date":"2026-11-01","description":{"long":"Kentyou is an innovative startup company helping cities in their digital transformation to face their environmental social and economic challenges more efficiently. By leveraging the open source Eclipse sensiNact platform, it provides a data hub that collects data from various data sources including IoT, mobile apps and open data portals, unifies and analyses that data to extract actionable information. Kentyou also provides a visualisation and impact monitoring tool to help cities making data-driven decisions with desirable effects with the help of emerging AI technologies. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1597-web.jpg"},"website":"https://kentyou.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"68db2919ffe553250ae8","description":"Participant Member","level":"WGAPS","working_group":"osgi"}],"is_active_member":true},{"organization_id":1599,"name":"SOTEC GmbH+Co KG","member_since":"2022-11-02","renewal_date":"2026-11-01","description":{"long":"SOTEC is an internationally active provider of software development and hardware solutions for the retail, automotive, industrial automation, manufacturing, and energy industries. SOTEC has been supporting its customers with advanced technology and development services for over 40 years. Services range from specialized hardware and embedded systems development to cloud architectures and solution implementations.\nAs a specialist for IoT (IIoT), Machine Learning, Industrie 4.0 and Cloud technologies, SOTEC supports customers in building digital platforms and thus in the digital transformation of their companies."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1599-web.png"},"website":"https://www.sotec.eu/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1600,"name":"Open Elements GmbH","member_since":"2022-11-08","renewal_date":"2026-12-01","description":{"long":"Open Elements is an IT company whose main focus is on the two points of Open Source Software (OSS) and Java. By focusing on these two points, we can provide our customers with expert advice and support in the development and use of Open Source Software. By specializing in Java-based OSS, we are members of the leading committees and foundations on these topics and actively contribute to the further development of critical open source systems in the Java ecosystem."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1600-web.png"},"website":"https://open-elements.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Participant Member","level":"WGAPS","working_group":"adoptium"},{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1604,"name":"Stellenbosch University","member_since":"2022-12-01","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Guest Member","level":"WGSAP","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1605,"name":"Micro Stream Software GmbH","member_since":"2022-12-16","renewal_date":"2026-12-01","description":{"long":"MicroStream connects Java seamlessly with the cloud. To do this, we create new innovations in Java, the JVM ecosystem, Android, data storage, and the cloud and work on standards together with other vendors and the strong open-source community. \n\nOur business is to support companies and organizations that use open source for their mission-critical projects commercially with enterprise add-ons, extended testing, custom-builds, first-class enterprise-grade support, and manpower."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1605-web.png"},"website":"https://microstream.one/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1606,"name":"Schaeffler","member_since":"2022-12-20","renewal_date":"2027-05-01","description":{"long":"The Schaeffler Group has been driving forward groundbreaking inventions and developments in the field of motion technology for over 75 years. With innovative technologies, products, and services for electric mobility, CO2-efficient drives, chassis solutions and renewable energies, the company is a reliable partner for making motion more efficient, intelligent, and sustainable – over the entire life cycle. We pioneer motion."},"logos":{"print":"https://membership.eclipse.org/organization/images/1606-print.eps","web":"https://membership.eclipse.org/organization/images/1606-web.png"},"website":"https://www.schaeffler.de","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1607,"name":"Valeo","member_since":"2022-12-20","renewal_date":"2027-01-01","description":{"long":"https://www.valeo.com/en/"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1607-web.png"},"website":"https://www.valeo.com/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1608,"name":"Cummins Inc","member_since":"2023-01-05","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1608-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1609,"name":"N3uron Connectivity Systems","member_since":"2023-01-10","renewal_date":"2027-01-01","description":{"long":"N3uron software is an Industrial Edge Platform for IIoT and DataOps that streamlines the flow of data between industrial systems and business applications, either on-premise or in the cloud. N3uron provides an out-of-the-box solution for data standardization, normalization and contextualization, seamless integration with industrial and IT systems, efficient information management, and unparalleled scalability and security. The N3uron platform makes it easier for operations teams to aggregate, manage and analyze industrial data, resulting in enhanced productivity and informed decision-making."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1609-web.png"},"website":"https://n3uron.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"f351fc9ba96cb468393f","description":"Participant Member","level":"WGAPS","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1611,"name":"NOUVELLE-AQUITAINE OPEN SOURCE","member_since":"2023-01-16","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1612,"name":"IAV ","member_since":"2023-01-18","renewal_date":"2027-02-01","description":{"long":"As one of the globally leading engineering partners, IAV develops the mobility of the future. Regardless of the specific manufacturer, our engineering proves itself in vehicles and technologies all over the world.\n\nWith more than 35 years of experience and an unsurpassed range of expertise, we combine the best of many different worlds: automotive and IT, hardware and software, products and services. With our workforce of more than 7,600 employees and first-class technical resources, we help our customers to implement their projects, from the concept right through to SOP. Our goal: better mobility.\n\nIAV offers outstanding engineering expertise and combines the best of many different worlds.\n\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1612-web.png"},"website":"https://www.iav.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1613,"name":"10xEngineers","member_since":"2023-01-24","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1613-web.jpg"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1614,"name":"SCANOSS","member_since":"2023-01-26","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1614-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1616,"name":"Start North ry","member_since":"2023-02-02","renewal_date":"2027-02-01","description":{"long":"Start North accelerates the learning and implementation of the latest technology in order to improve the productivity of companies and promote the world's sustainable development. Together with its university and business partners, Start North plans and implements programs and projects and implements 5G Mokki Tech Space learning, innovation, remote work and service environments for university campuses and wherever know-how, work and services are needed."},"logos":{"print":null,"web":null},"website":"https://www.startnorth.com/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1619,"name":"Gaia-x European Association for Data and Cloud.","member_since":"2023-02-27","renewal_date":"2027-03-01","description":{"long":"The Gaia-X European Association for Data and Cloud AISBL\nInnovation through digital sovereignty – that’s the goal of Gaia-X. We achieve this by establishing an ecosystem in which data is made available, collated and shared in a trustworthy environment. The users always retain sovereignty over their data. So, what emerges is not a cloud but a federated system that links many cloud services providers and users together."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1619-web.png"},"website":"https://gaia-x.eu","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1620,"name":"Beijing Institute of Open Source Chip","member_since":"2023-03-16","renewal_date":"2026-08-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1620-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1621,"name":"LG Electronics, Inc","member_since":"2023-03-21","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1621-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1625,"name":"Open Forum Europe AISBL","member_since":"2023-04-13","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1625-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1629,"name":"Posit Software, PBC","member_since":"2023-05-04","renewal_date":"2027-05-01","description":{"long":"Posit helps people understand and improve the world through data. We build tools that enable robust and reproducible data analysis through a code-first approach, paired with tools that make it easy to share insights. Our core software is open source, freely available to anyone. Our professional software equips individuals and teams to develop and share their work at scale."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1629-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"}],"is_active_member":true},{"organization_id":1630,"name":"Reutlingen University","member_since":"2023-05-10","renewal_date":"2027-05-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1630-web.png"},"website":"https://www.reutlingen-university.de","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1631,"name":"Litmus Automation Inc.","member_since":"2023-05-11","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1631-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Participant Member","level":"WGAPS","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1632,"name":"Qualcomm Innovation Center","member_since":"2023-05-24","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1632-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1633,"name":"KU Leuven","member_since":"2023-06-12","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1633-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1634,"name":"Ferdinand-Steinbeis-Institut","member_since":"2023-06-14","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1634-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1635,"name":"Energy Telecommunications & Electrical Association","member_since":"2023-06-28","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1635-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Guest Member","level":"WGSAP","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1636,"name":"Politecnico di Torino","member_since":"2023-07-06","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1638,"name":"Integration Objects","member_since":"2023-10-02","renewal_date":"2026-10-01","description":{"long":"Integration Objects empowers businesses to accelerate their digital transformation through robust and reliable solutions. We offer a wide range of applications including, Industrial IoT (IIoT), cyber security, Big Data Analytics, C4ISR, and process automation for Defense and Governmental Institutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1638-web.png"},"website":"https://integrationobjects.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Participant Member","level":"WGAPS","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1640,"name":"GPS BY DESIGN CENTRE","member_since":"2023-10-12","renewal_date":"2026-10-01","description":{"long":"Our mission is to spread the word on how to operationalize Privacy by Design, especially given its inclusion in the new E.U. General Data Protection Regulation. "},"logos":{"print":null,"web":null},"website":"https://gpsbydesigncentre.com/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1641,"name":"International Data Spaces e. V","member_since":"2023-11-02","renewal_date":"2026-10-01","description":{"long":"The International Data Spaces Association (IDSA) is on a mission to create the future of the global, digital economy. Its 170+ member companies and institutions have created the International Data Spaces (IDS) standard: a secure system of sovereign and trusted data sharing in which all participants can realize the full value of their data. IDS enables new smart services and innovative business processes to work across companies and industries while ensuring that the control of data remains in the hands of data providers. We call this data sovereignty."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1641-web.jpg"},"website":"https://internationaldataspaces.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1642,"name":"PX5","member_since":"2023-11-03","renewal_date":"2026-11-01","description":{"long":"Expert Professional Support for THREADX RTOS and middleware!\n\nWith decades of THREADX domain experience, our team delivers professional, fully ticketed, and tracked support for individual projects through entire enterprises. Being the original authors, nobody knows the THREADX technology more than us. We are committed to taking care of you!\n\nhttps://rtosx.com\n\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1642-web.png"},"website":"https://rtosx.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1643,"name":"iSHARE Foundation","member_since":"2023-11-08","renewal_date":"2026-11-01","description":{"long":"Non-profit trust and participant governance framework for data exchange between organisations in data spaces. Bringing organisational and trust interoperability. \n\nTrust derived from Legal, Operational and Technical credentials and specifications. \n\nGoverned by the data spaces that build on iSHARE and licence the specifications and operational and legal documentation to govern data spaces. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1643-web.jpg"},"website":"https://ishare.eu","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1645,"name":"Amazon Europe Core SARL","member_since":"2023-11-16","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1645-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"}],"is_active_member":true},{"organization_id":1646,"name":"Cypherbridge Systems LLC","member_since":"2023-11-15","renewal_date":"2026-11-01","description":{"long":"Cypherbridge develops and deploys purpose-built IoT security software solutions to meet industry standards, regulation, and cybersecurity requirements throughout the product lifecycle.\n\t\nFrom concept to product, Cypherbridge delivers solutions for Eclipse ThreadX platforms, including secure boot, connectivity, security, and IoT Cloud Computing. We offer SDKPac for Eclipse ThreadX, porting and design services, and long term technical support for complete solution delivery and software lifecycle."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1646-web.jpg"},"website":"https://www.cypherbridge.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1648,"name":"co4e GmbH","member_since":"2024-01-01","renewal_date":"2027-01-01","description":{"long":"The Consultancy for Engineers (co4e) GmbH is a software tool vendor and consultancy service provider. It was founded in 2019 as a spin-off from the German Aerospace Center (DLR). The co4e GmbH head office located in the heart of Berlin (Kreuzberg), Germany.

    Established with a vision to address the complexities of transportation systems, we bring together a team of experts and enthusiasts who are passionate about creating sustainable, efficient, and intelligent mobility solutions. At the heart of our endeavors are SESAM, a cloud platform designed for mobility simulations, and ASSIST, a tool suite to automate the design of safety-critical systems."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1648-web.png"},"website":"https://www.co4e.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1649,"name":"Sonatype Inc.","member_since":"2023-12-07","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1649-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1651,"name":"Johannes Kepler University Linz","member_since":"2023-12-12","renewal_date":"2027-01-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1651-web.png"},"website":"https://www.jku.at","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1653,"name":"Nordic Institute for Interoperability Solutions","member_since":"2024-01-05","renewal_date":"2027-01-01","description":{"long":"Nordic Institute for Interoperability Solutions (NIIS) ensures the development and strategic management of digital government solutions that allow NIIS members to provide excellent digital public services.\n\nNIIS is both a network and cooperation platform and executioner of IT developments in members’ common interests. The institute focuses on practical collaboration, sharing of experience and promoting innovation. The operating model of the institute is something unique in the world.\n\nThe republics of Estonia, Finland and Iceland are members of NIIS, and the Faroe Islands and the Government of Åland are partners of NIIS."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1653-web.png"},"website":"https://www.niis.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1654,"name":"Harman International","member_since":"2024-01-08","renewal_date":"2027-01-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1654-web.jpg"},"website":"https://www.harman.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1655,"name":"The Matrix.org Foundation C.I.C.","member_since":"2024-01-19","renewal_date":"2027-02-01","description":{"long":"Matrix is an open protocol for decentralised, secure communications. The Matrix.org Foundation exists to act as a neutral custodian for Matrix and to nurture it as efficiently as possible as a single unfragmented standard, for the greater benefit of the whole ecosystem, not benefiting or privileging any single player or subset of players."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1655-web.png"},"website":"https://matrix.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1656,"name":"Catena-X Automotive Network e.V","member_since":"2024-02-06","renewal_date":"2027-01-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1656-web.png"},"website":"https://catena-x.net/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1659,"name":"Lunatech Labs B.V.","member_since":"2024-02-27","renewal_date":"2027-03-01","description":{"long":"Lunatech, established in 1993, is a distinguished software development consultancy renowned for its expertise in crafting tailored solutions to address intricate challenges. Specialising in the design, development, deployment, and ongoing operation of custom software, Lunatech excels in delivering comprehensive services.\n\nWith a team of experts proficient in Java and Scala, Lunatech excels in various domains including system integration, legacy transformation, and continuous maintenance. With three decades of experience under our belt, we have empowered our clients to streamline their IT operations and achieve their business objectives seamlessly."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1659-web.png"},"website":"https://www.lunatech.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1661,"name":"FEV.io GmbH","member_since":"2026-03-01","renewal_date":"2027-02-01","description":{"long":""},"logos":{"print":"https://membership.eclipse.org/organization/images/1661-print.eps","web":"https://membership.eclipse.org/organization/images/1661-web.png"},"website":"https://www.fev.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1663,"name":"Instituto Tecnológico de Informática","member_since":"2024-03-12","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1663-web.jpg"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1666,"name":"Stadt Jena","member_since":"2024-03-21","renewal_date":"2027-04-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1666-web.png"},"website":"https://www.jena.de","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1667,"name":"TOSIT Association","member_since":"2024-03-25","renewal_date":"2027-04-01","description":{"long":"TOSIT (The Open Source I Trust) is an association under the French Law of 1901 of major end-users, with the following aims:\n\n* Provide a forum for its members to meet and discuss Open Source solutions\n\n* Encourage the sharing of feedback and best practice in Open Source\n\n* Gather and identify the needs of its members in terms of Open Source solutions\n\n* Carry out strategic or technical studies and monitoring related to Open Source solutions\n\n* Promote Open Source solutions judged to be the most effective in various areas of interest\n\n* Carry out communication and publication initiatives related to Open Source \n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1667-web.png"},"website":"https://tosit.fr","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1669,"name":"Ferrous Systems GmbH","member_since":"2024-04-08","renewal_date":"2027-05-01","description":{"long":"Ferrous Systems is worlds leading Rust company. From tooling, to support, to training. They are the first one to implement and certify a fully open source Rust compiler usable in safety, by ISO 26262 and IEC 61508.\n\nMembers of the company have been in Rust Foundation and Rust Project leadership for a long while."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1669-web.png"},"website":"https://ferrous-systems.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1670,"name":"Rust Foundation","member_since":"2024-04-11","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1670-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1672,"name":"DIN e.V.","member_since":"2024-04-30","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1673,"name":"Python Software Foundation","member_since":"2024-05-01","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1673-web.jpg"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1674,"name":"The PHP Foundation (Open Source Collective)","member_since":"2024-05-06","renewal_date":"2027-05-01","description":{"long":"We support, advance, and develop the PHP Language."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1674-web.png"},"website":"https://thephp.foundation","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1675,"name":"OpenSSL Software Foundation Inc","member_since":"2024-05-22","renewal_date":"2027-05-01","description":{"long":"The OpenSSL Foundation works to ensure that everyone, including nonprofits, academics, and independent developers, has access to fundamental data privacy and security tools that are the backbone of internet protection, quietly safeguarding millions of users. We do this to help build a safer internet — one that serves the public interest and upholds privacy and security as foundational rights."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1675-web.png"},"website":"https://openssl-foundation.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1676,"name":"OWASP Foundation, Inc.","member_since":"2024-05-26","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1676-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1677,"name":"THE COMETBID SOFTWARE FOUNDATION","member_since":"2024-05-30","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1678,"name":"XITASO GmbH","member_since":"2024-06-03","renewal_date":"2026-06-01","description":{"long":"As a digitization partner and expert for high-end software engineering, XITASO provides advice to B2B customers, identifies digitization potentials, optimizes business processes and create digital strategies and solutions. Based on an agile mindset, we design and develop individual solutions with outstanding expertise in the areas of Industry 4.0, Internet of Things (IoT), Robotics, Digital Twin, Data Science, Artificial Intelligence and Augmented Reality. XITASO serves customers throughout Germany from various industries, in particular from mechanical and plant engineering as well as the healthcare sector."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1678-web.png"},"website":"https://xitaso.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1679,"name":"Michelin","member_since":"2024-06-06","renewal_date":"2026-06-01","description":{"long":"Michelin is building a world-leading manufacturer of life-changing composites and experiences.\n\nPioneering engineered materials for more than 130 years, Michelin is uniquely positioned to make decisive contributions to human progress and a more sustainable world."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1679-web.png"},"website":"https://www.michelin.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1680,"name":"Stichting Blender Foundation","member_since":"2024-06-06","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1680-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1681,"name":"Clever Cloud SAS","member_since":"2024-06-06","renewal_date":"2026-06-01","description":{"long":"Founded in 2010, Clever Cloud is a French company based in Nantes, specialising in IT automation. It creates and supplies the software building blocks needed to deploy applications on self-service PaaS architectures. Its customers include such big names as Airbus, Great Place to Work, MAIF, Cegid, Docaposte, Fairphone, Solocal and TBWA."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1681-web.png"},"website":"https://www.clever.cloud/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1682,"name":"CodeDay","member_since":"2024-06-06","renewal_date":"2026-06-01","description":{"long":"There's a place in tech for everyone. CodeDay is a non-profit providing welcoming, hands-on opportunities for under-served students to explore a future in tech and beyond through opportunities to contribute to open-source software."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1682-web.png"},"website":"https://www.codeday.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Guest Member","level":"WGSAP","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1683,"name":"ZHAW, Institute of Mechatronic Systems (IMS)","member_since":"2024-06-13","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1684,"name":"The Document Foundation","member_since":"2024-06-13","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1684-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1685,"name":"Open Infrastructure Foundation","member_since":"2024-06-17","renewal_date":"2026-06-01","description":{"long":"The Open Infrastructure Foundation (previously known as the OpenStack Foundation) is a global non-profit organization providing a neutral, open environment for organizations, developers, and users to build open source infrastructure software together.\n\nStrong of more than 110,000 individual members representing 700+ organizations in 180+ countries, our Foundation is the home for several open source infrastructure projects, including OpenStack, Kata Containers and StarlingX."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1685-web.png"},"website":"https://openinfra.dev","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1686,"name":"Stichting NLnet Labs","member_since":"2024-06-19","renewal_date":"2026-06-01","description":{"long":"Founded in 1999, NLnet Labs is an independent, non-profit, public benefit foundation based in the Netherlands. Our mission is to make the core of the Internet a better, safer place by developing open-source software, through applied research and by promoting and contributing to open standards."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1686-web.png"},"website":"https://nlnetlabs.nl","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1688,"name":"FreeBSD Foundation","member_since":"2024-06-26","renewal_date":"2026-07-01","description":{"long":"The FreeBSD Foundation is a 501(c)(3) non-profit organization supporting the FreeBSD Project and community. Accepting donations from individuals and businesses, the Foundation uses funds to develop features, employ software engineers, improve build and test infrastructure, advocate for FreeBSD through in-person and online events, and provide training and educational material. Representing the FreeBSD Project in legal affairs, the Foundation is the recognized entity for contracts, licenses, and other legal arrangements and is entirely donation-supported. Learn more at freebsdfoundation.org"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1688-web.png"},"website":"https://www.freebsdfoundation.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1689,"name":"Yildiz Technical University","member_since":"2024-06-26","renewal_date":"2026-07-01","description":{"long":"Established in 1911, Yildiz Technical University (YTU) is one of Turkey's oldest and most prestigious technical universities. With around 35,000 students and over 1,500 academic staff, YTU offers interdisciplinary programs in engineering, natural sciences, social sciences, and arts. Our modern campus supports student-centered learning, enriched by student clubs and research facilities. Internationally recognized for research, YTU collaborates on various national and global projects, aiming to advance education, research, and innovation to tackle global challenges."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1689-web.png"},"website":"https://www.yildiz.edu.tr/en","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1690,"name":"useblocks GmbH","member_since":"2024-06-26","renewal_date":"2026-07-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1690-web.png"},"website":"https://useblocks.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1691,"name":"3DS Outscale","member_since":"2024-06-26","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1693,"name":"Qorix GmbH","member_since":"2024-07-08","renewal_date":"2026-07-01","description":{"long":"Qorix is a leading provider of middleware software and engineering services with a specialized focus on the\nautomotive industry. Our offerings are:\n1- Qorix Classic stack\n2- Qorix Adaptive stack\n3- Qorix Performance stack\n4- Qorix Developer: Designer & SDK\n5- Engineering Services: maintenance, support & customization."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1693-web.png"},"website":"https://www.qorix.ai/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1695,"name":"L&T Technology Services Ltd","member_since":"2024-08-22","renewal_date":"2026-09-01","description":{"long":"L&T Technology Services Limited (LTTS) is a global leader in Engineering and R&D (ER&D) services. With 1,343 patents filed for 57 of the Global Top 100 ER&D spenders, LTTS lives and breathes engineering. Our innovations speak for themselves – World’s 1st Autonomous Welding Robot, Solar ‘Connectivity’ Drone, and the Smartest Campus in the World, to name a few.\nLTTS’ expertise in engineering design, product development, smart manufacturing, and digitalization touches every area of human lives. With 108 Innovation and R&D design centers globally, we specialize in disruptive technology spaces such as NexGen Comms, Artificial Intelligence, Digital Factory, and Autonomous Transport."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1695-web.jpg"},"website":"https://www.ltts.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1696,"name":"Allison Transmission, Inc.","member_since":"2024-08-22","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1696-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1697,"name":"ekxide IO GmbH","member_since":"2024-09-04","renewal_date":"2026-10-01","description":{"long":"ekxide is the innovative force behind iceoryx and iceoryx2. Founded by the core maintainers and creators of iceoryx, the company was established to propel the development and ensure the continued success of the open-source project. ekxide provides a range of services focused on iceoryx, including commercial extensions and tooling, accelerated development, safety certification, priority bug-fixing, and expert training and consulting. These services are designed to enhance the performance, reliability, and safety of iceoryx-based solutions. ekxide supports clients with tailored solutions to meet their specific needs in this area."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1697-web.png"},"website":"https://ekxide.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1698,"name":"Instituto de Telecomunicações","member_since":"2024-09-06","renewal_date":"2026-09-01","description":{"long":"Instituto de Telecomunicações (IT) is a private, not-for-profit organization, of public interest, a partnership of nine institutions with research and development in the field of Telecommunications.\n\nIT is actively involved in fundamental and applied research both at national and international levels. IT also plays its role towards public society with public awareness initiatives, knowledge transfer to industry, and by providing consulting services on a non-competing basis."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1698-web.png"},"website":"https://it.pt","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1699,"name":"I Machines, Inc","member_since":"2024-09-09","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1699-web.jpg"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1700,"name":"Ruby Central, Inc.","member_since":"2024-09-09","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1700-web.jpg"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1702,"name":"Ejad for Engineering Systems","member_since":"2024-09-13","renewal_date":"2026-09-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1702-web.jpg"},"website":"https://www.ejad.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1703,"name":"Software Heritage Foundation - Inria Foundation","member_since":"2024-09-20","renewal_date":"2026-10-01","description":{"long":"Software Heritage is a non-profit initiative dedicated to collecting, preserving, and sharing all publicly available source code for the long term. Launched by Inria, supported by UNESCO, Software Heritage operates as the largest archive of open-source software, hosting over 50 billion software artifacts. Its mission is to ensure that software, a vital part of our digital heritage, is safeguarded and accessible to future generations. By enabling traceability and fostering collaboration, Software Heritage serves as an invaluable resource for research, industry, and society at large."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1703-web.png"},"website":"https://softwareheritage.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1704,"name":"Open Source Initiative","member_since":"2024-09-23","renewal_date":"2026-10-01","description":{"long":"The OSI is the authority that defines Open Source, recognized globally by individuals, companies, and by public institutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1704-web.jpg"},"website":"https://opensource.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1705,"name":"Ostfalia University","member_since":"2024-10-15","renewal_date":"2026-10-01","description":{"long":"The Faculty of Computer Science has existed for 30 years and has grown continuously with 24 professors and over 1000 students. Our range of courses includes courses that require typical on-campus study as well as courses that are offered in a purely online format. At the Faculty of Computer Science one can study five Bachelor programs and two Master degree programs. The online format offers two Bachelor and two Master degree programs."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1705-web.png"},"website":"https://www.ostfalia.de/cms/de/i/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Guest Member","level":"WGSAP","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1707,"name":"Tekniker","member_since":"2024-10-24","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1708,"name":"Navigation Data Standard (NDS) e.V.","member_since":"2024-10-24","renewal_date":"2026-11-01","description":{"long":"The NDS Association provides the global standard for map data within automotive ecosystems. Its members include car manufacturers, application developers, compiler developers, as well as map and service providers.\n\nThe NDS.Live standard enables the transmission of dynamic, cloud-connected data. It addresses the increasing size of map data by ensuring that only necessary updates are transmitted over data connections. NDS.Live has a highly modular architecture and supports various types of data, making it adaptable for a range of automotive applications."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1708-web.png"},"website":"https://nds-association.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1709,"name":"Acatech - Deutsche Akademie der Technikwissenschaften e.V.","member_since":"2024-10-31","renewal_date":"2026-11-01","description":{"long":""},"logos":{"print":null,"web":null},"website":"https://www.acatech.de/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1710,"name":"AboutCode Europe ASBL","member_since":"2024-11-05","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1710-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1711,"name":"KPIT Technologies Ltd","member_since":"2024-11-08","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1711-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1713,"name":"Cyberismo","member_since":"2024-11-25","renewal_date":"2026-12-01","description":{"long":"Cyberismo is a cybersecurity solution company dedicated to fortifying the digital landscape. We base our approach on the open-source Cyberismo solution, open collaboration, cybersecurity consulting, and the courage to focus on delivering impactful results. We simplify and optimise cybersecurity management while aiding teams in integrating cybersecurity into their daily operations."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1713-web.png"},"website":"https://cyberismo.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1714,"name":"OpenNebula Systems SL","member_since":"2024-12-03","renewal_date":"2027-01-01","description":{"long":"First released in Spain in 2008 as the outcome of a research project, OpenNebula has evolved into the main European open source cloud & edge management platform. As a Virtualized Infrastructure Manager (VIM) and IaaS solution, it unifies support for virtual machines, containers, and Kubernetes clusters, while providing federation, multi-tenancy, and automated provisioning across datacenter, cloud, and edge environments."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1714-web.png"},"website":"https://opennebula.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1716,"name":"Tauri","member_since":"2024-12-17","renewal_date":"2027-01-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1719,"name":"Double Open","member_since":"2024-12-20","renewal_date":"2027-01-01","description":{"long":"Double Open combines specialized compliance knowledge with the transparency of the industry's leading open toolset."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1719-web.png"},"website":"https://www.doubleopen.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1720,"name":"Welotec GmbH","member_since":"2024-12-20","renewal_date":"2027-01-01","description":{"long":"Founded in 1969 with headquarters in Germany, Welotec boasts a strong team with a deep understanding of the needs of machine builders. We specialize in Edge Computing, Cloud Integration, and are committed to Open Source solutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1720-web.png"},"website":"https://www.welotec.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1721,"name":"GEA Group AG","member_since":"2024-12-20","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1721-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1722,"name":"Codethink Ltd.","member_since":"2025-01-02","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1722-web.png"},"website":"","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1723,"name":"Vates","member_since":"2024-12-19","renewal_date":"2027-01-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1724,"name":"Erlang Ecosystem Foundation","member_since":"2025-01-06","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1724-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1726,"name":"Overnet Solutions S.r.l","member_since":"2025-01-24","renewal_date":"2027-02-01","description":{"long":"With over 30 years of experience in ICT training, Overnet is a leader in Italy’s ICT education sector. We offer the broadest range of official IT training and continuously update our programs to address all aspects of digital transformation. Companies and professionals looking to excel in the tech evolution trust us to develop their digital skills.\n\nOvernet is your fast track to Open Source Cloud Adoption. Our solutions enable your team to seamlessly adopt open source technologies across existing and new cloud providers, embracing hybrid and portable cloud workloads."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1726-web.png"},"website":"https://overnet.education/open-source-cloud-adoption","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1728,"name":"Associação 101010","member_since":"2025-01-30","renewal_date":"2027-02-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1729,"name":"Transcality AG","member_since":"2025-02-06","renewal_date":"2027-02-01","description":{"long":"We build a digital replica of traffic to evaluate the present and plan the future."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1729-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1736,"name":"Cofinity-X GmbH","member_since":"2025-02-18","renewal_date":"2027-03-01","description":{"long":"Cofinity-X is a joint venture established by several major companies, including BMW, Mercedes-Benz, SAP, BASF and ZF, to create a secure and efficient data exchange network in the automotive industry. This initiative aims to address the growing need for seamless and secure data sharing among automotive manufacturers, suppliers and other stakeholders. Cofinity-X represents a significant step forward in addressing the complexities and challenges of data management in the modern industry. Its collaborative approach and use of cutting-edge technology position it as a key player in the future of data exchange."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1736-web.png"},"website":"https://www.cofinity-x.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1737,"name":"Hyundai Mobis","member_since":"2025-02-20","renewal_date":"2027-03-01","description":{"long":"As a global auto parts vendor, we focus on autonomous driving, connectivity and electrification to be a leader in the era of smart mobility. Based on three modular auto components (i.e. chassis, cockpit and front-end), we work to make driving safer and easier and also offer service parts that can best serve the purpose.\n\nOur vision is to be a provider of differentiated mobility solutions that combine software and hardware in the upcoming mobility industry. To make this vision a reality, we have expanded our business areas to include smart mobility, UAM and robotics based on our R&D capability and production capacity."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1737-web.png"},"website":"https://www.mobis.com/en/index.do","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1738,"name":"Ant Blockchain Technology (Shanghai) Co., Ltd","member_since":"2025-02-26","renewal_date":"2027-03-01","description":{"long":"Ant Digital Technology is an independent section of Ant Group's technology commercialization, which began independent operations in April 2024. Ant Digital Technology started with Ant Chain and has the world's largest number of leading technologies and patents in the blockchain field. In addition, it has continuously developed multiple commercial product brands, including ZOLOZ, mPaaS, SofaStack, Ant Shield, and Ant Tianjian.As of now, Ant Digital Technology has collaborated with over 300 partners to serve more than 10,000 enterprise customers."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1738-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1740,"name":"Universidad Politécnica de Madrid","member_since":"2025-02-27","renewal_date":"2027-03-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1740-web.png"},"website":"https://upm.es","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1741,"name":"Drupal Association","member_since":"2025-02-27","renewal_date":"2027-03-01","description":{"long":"The Drupal Association is the non-profit organization focused on accelerating Drupal, fostering the growth of the Drupal community, and supporting the project’s vision to create a safe, secure, and open web for everyone. The Drupal Association also administers Drupal.org on behalf of the Drupal community."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1741-web.png"},"website":"https://www.drupal.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1742,"name":"Capabilities Limited","member_since":"2025-03-05","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1742-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1744,"name":"Debian France","member_since":"2025-03-20","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1745,"name":"APELL ASBL","member_since":"2025-04-03","renewal_date":"2027-04-01","description":{"long":"APELL – The European Open Source Software Business Association is the umbrella organisation for national Open Source business associations in Europe. Founded in 2020, it aims to increase opportunities for the members of the Association’s member organisations, and to raise awareness for the strategic importance of Open Source for Europe. APELL promotes a sovereign, in­clu­sive, ethical digital market."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1745-web.png"},"website":"https://apell.info/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1746,"name":"the School of ECE of NTUA","member_since":"2025-04-09","renewal_date":"2027-04-01","description":{"long":"School of Electrical and Computer Engineering of the National Technical University of Athens"},"logos":{"print":null,"web":null},"website":"https://www.ece.ntua.gr/en","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1747,"name":"Liebherr-Digital Development Center GmbH","member_since":"2025-04-23","renewal_date":"2027-04-01","description":{"long":"The Liebherr Group is a family-run technology company with a highly diversified product programme. The company is one of the largest construction equipment manufacturers in the world. It also provides high-quality, user-oriented products and services in a wide range of other areas. The Liebherr Group includes over 150 companies across all continents. In 2023, it employed more than 50,000 staff and achieved combined revenues of over 14 billion euros."},"logos":{"print":"https://membership.eclipse.org/organization/images/1747-print.eps","web":"https://membership.eclipse.org/organization/images/1747-web.png"},"website":"https://www.liebherr.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1748,"name":"The IO Foundation","member_since":"2025-04-24","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1748-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1749,"name":"EGI Foundation","member_since":"2025-05-06","renewal_date":"2026-06-01","description":{"long":"The EGI Foundation is the coordinating body of the EGI Federation. It offers a federation and management platform that enables service providers to harmonise interfaces and connect to a common hub.\nThe EGI Federation is the scalable digital infrastructure resulting from this coordination, serving thousands of researchers across disciplines. It provides advanced computing and data analytics capabilities through hundreds of public and private service providers, offering distributed computing, storage solutions, co-development opportunities, expert support, and training to propel scientific collaboration and innovation."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1749-web.png"},"website":"https://www.egi.eu","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"},{"document_id":"df911e0adcad1a1c51df","description":"Guest Member","level":"WGSAP","working_group":"asciidoc"}],"is_active_member":true},{"organization_id":1751,"name":"Stichting Connekt","member_since":"2025-05-09","renewal_date":"2027-05-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1752,"name":"Open Source Matters Inc.","member_since":"2025-06-11","renewal_date":"2026-06-01","description":{"long":"Open Source Matters (OSM) is a not-for-profit organisation, incorporated in the United States, created to serve the financial and legal interests of the Joomla project. OSM has been designed to be flexible and change as the needs of Joomla! expand. At all times, OSM is fashioned to suit the needs of the Joomla project. OSM will also engage in regular self-assessment to ensure it is accountable to Joomla!, acting in Joomla!'s interest and ensuring that it is the right shape and size to support Joomla!."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1752-web.png"},"website":"https://www.joomla.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1754,"name":"GitHub","member_since":"2025-07-08","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1754-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1755,"name":"Engineering Ingegneria Informatica","member_since":"2025-07-22","renewal_date":"2026-08-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1755-web.png"},"website":"https://eng.it/en","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1756,"name":"ONERA DTIS","member_since":"2025-07-24","renewal_date":"2026-08-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1758,"name":"ifrOSS","member_since":"2025-09-02","renewal_date":"2026-09-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1760,"name":"Validas AG","member_since":"2025-09-09","renewal_date":"2026-09-01","description":{"long":"Validas is the driving force behind safe tools, libraries, and basic software. For 25 years, we have been supporting our international customers from the automotive, aerospace, and semiconductor industries with the qualification of tools, libraries, and basic software, as well as powerful qualification kits for code generators, compilers, and simulators. This ensures that the software used in cars, airplanes, or complex technical systems meets the highest safety requirements and common safety standards such as ISO 26262 or IEC 61508."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1760-web.png"},"website":"https://www.validas.de/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1761,"name":"Open Source Society Malta","member_since":"2025-09-24","renewal_date":"2026-09-01","description":{"long":"OSSMalta.eu is the premier open source community in Malta, fostering collaboration and knowledge-sharing. It promotes the adoption of open source technologies through educational initiatives and community building. As a member of the Eclipse Foundation's Open Regulatory Compliance Working Group (ORC WG), OSSMalta contributes to developing best practices and guidelines for open source actors to meet evolving regulatory requirements, such as those from the European Cyber Resilience Act. This membership reinforces our commitment to ensuring open source remains a viable and compliant option for developers and businesses across Europe."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1761-web.png"},"website":"https://ossmalta.eu","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1762,"name":"Brightskies","member_since":"2025-10-02","renewal_date":"2026-10-01","description":{"long":"Brightskies is a digital transformation enabler and market leader founded in 2012 with more than 400 employees. With over a decade of experience working closely with more than 50 clients, we guarantee exceptional results to help your business succeed and stand out.\nOur Automotive Services team has very strong experience developing safety-critical automotive systems to most of the car makers around the globe from the classical car makers where safety, security and certification represent the core principals to the disruptive ones where performance, technology and software-defined features are the main theme."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1762-web.png"},"website":"https://brightskiesinc.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1763,"name":"RT-RK DOO Novi Sad","member_since":"2025-10-06","renewal_date":"2026-10-01","description":{"long":"RT-RK is a premium embedded engineering company with over 30 years of experience and 600+ engineers. We help global leaders in the automotive, consumer electronics, and semiconductor industries turn complex ideas into dependable real-time systems. With expertise in both hardware and software development, RT-RK provides scalable technology and resource solutions that enable faster innovation, higher efficiency, and products built to perform at scale."},"logos":{"print":"https://membership.eclipse.org/organization/images/1763-print.eps","web":"https://membership.eclipse.org/organization/images/1763-web.png"},"website":"https://rt-rk.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1764,"name":"ZIUR Foundation","member_since":"2025-10-14","renewal_date":"2026-10-01","description":{"long":"Industrial Cybersecurity Center of Gipuzkoa\nWe are a public initiative created by the Gipuzkoa Provincial Council to help industrial companies reinforce their protection and that of their products or services against cyberattacks.\n\nWe live in a connected world that advances at a great speed. From ZIUR we help you go through that road of opportunities and threats with greater security.\n\nWe want to promote greater safety barriers against cyberthreats in the industrial field, to revitalize the sector of cybersecurity and to contribute to the competitiveness of the companies of our territory"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1764-web.png"},"website":"https://www.ziur.eus","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1767,"name":"Infosys Limited","member_since":"2025-10-27","renewal_date":"2026-11-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1767-web.png"},"website":"https://infosys.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1768,"name":"SignPath Foundation","member_since":"2025-11-10","renewal_date":"2026-11-01","description":{"long":"The SignPath Foundation supports open source projects by providing code signing certificates and a secure signing process through SignPath.io. We verify that binaries are built from the project’s public repository, eliminating the need for personal identity checks. Private keys are securely generated and stored on our HSM, enabling simple integration into automated build pipelines. Our goal is to make trustworthy software delivery accessible to OSS projects, and all services are free of charge."},"logos":{"print":"https://membership.eclipse.org/organization/images/1768-print.eps","web":"https://membership.eclipse.org/organization/images/1768-web.png"},"website":"https://signpath.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1769,"name":"WirelessCar","member_since":"2025-11-17","renewal_date":"2026-11-01","description":{"long":"WirelessCar is a leading innovator of digital vehicle services, accelerating the transformation toward software-defined mobility. With over 25 years of experience, we turn connected vehicle data into business value through scalable, cloud-based solutions spanning connectivity, journey intelligence, safety, and EV services. Connecting more than 17 million vehicles in over 100 countries, WirelessCar collaborates with global OEMs and industry partners to leverage the full value of connected services to empower future mobility."},"logos":{"print":"https://membership.eclipse.org/organization/images/1769-print.eps","web":"https://membership.eclipse.org/organization/images/1769-web.jpg"},"website":"https://www.wirelesscar.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1770,"name":"Libelium","member_since":"2025-11-18","renewal_date":"2026-11-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Participant Member","level":"WGAPS","working_group":"dataspace"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1771,"name":"mtrail Deutschland GmbH","member_since":"2025-11-24","renewal_date":"2026-11-01","description":{"long":"mtrail GmbH is a specialized Swiss engineering and software company that develops technology solutions for the international railway industry. Their services focus on traffic management, infrastructure modeling, and AI-based image recognition, notably through products like \"TrainVision\" and the \"RCS\" (Rail Control System) family. They cater primarily to major European railway operators and infrastructure managers, including Swiss Federal Railways (SBB), Deutsche Bahn (DB), and Infrabel."},"logos":{"print":"https://membership.eclipse.org/organization/images/1771-print.eps","web":"https://membership.eclipse.org/organization/images/1771-web.jpg"},"website":"http://www.mtrail.de","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fb4d6a3ddca7cfc1de0d","description":"","level":"WGSM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1775,"name":"Openchip & Software Technologies S.L.","member_since":"2025-12-11","renewal_date":"2026-12-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1776,"name":"TRATON AB","member_since":"2025-12-21","renewal_date":"2027-01-01","description":{"long":"With its brands Scania, MAN, International, and Volkswagen Truck & Bus, the TRATON GROUP is one of the world’s leading commercial vehicle manufacturers. The Group’s product portfolio comprises trucks, buses, and light-duty commercial vehicles. “Transforming Transportation Together. For a sustainable world.”: this intention underlines the Company’s ambition to have a lasting and sustainable impact on the commercial vehicle business and on the Group’s commercial growth."},"logos":{"print":"https://membership.eclipse.org/organization/images/1776-print.eps","web":"https://membership.eclipse.org/organization/images/1776-web.png"},"website":"https://traton.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1777,"name":"LG CNS","member_since":"2025-12-21","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1777-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1778,"name":"Fondazione CHIPS-IT","member_since":"2026-01-02","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1778-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1779,"name":"Associação TICE.PT","member_since":"2026-01-05","renewal_date":"2027-01-01","description":{"long":"TICE.PT is the Portuguese national cluster for Information, Communication, and Electronic Technologies, bringing together companies, universities, research centers, and other relevant entities in the sector. Officially recognized since 2009, the cluster acts as a collaborative platform that promotes innovation, knowledge transfer, and technological development, strengthening the competitiveness of the digital economy in Portugal.\n\nThrough cooperation among its members, TICE.PT seeks to enhance the national technological offering, support research and development projects, stimulate the creation of innovative products and services, and boost the internationalization of Portuguese companies."},"logos":{"print":"https://membership.eclipse.org/organization/images/1779-print.eps","web":"https://membership.eclipse.org/organization/images/1779-web.jpg"},"website":"https://tice.pt/en","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"},{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1780,"name":"Nilux GmbH","member_since":"2026-01-07","renewal_date":"2027-01-01","description":{"long":"Nilux GmbH is a Germany-based automotive software partner driving the transition toward Software-Defined Vehicles. We enable OEMs and Tier-1s to evolve from legacy, ECU-centric systems to scalable SDV architectures through AUTOSAR Classic & Adaptive, middleware, vehicle abstraction, cloud integration, and automotive cybersecurity. As an Eclipse SDV supporting member, Nilux positions itself as a pioneer service partner for SDV strategy, migration, and industrialization, translating open-source SDV innovation into production-ready, safety-compliant vehicle platforms."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1780-web.png"},"website":"https://nilux-gmbh.de/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1781,"name":"lowRISC C.I.C.","member_since":"2026-01-19","renewal_date":"2027-02-01","description":{"long":"Open Silicon Everywhere™\n\nlowRISC® C.I.C. (Community Interest Company) is a regulated not-for-profit company with a mission to help make open-source silicon a reality, commercially relevant, and widely adopted throughout the industry. \nWe aim to bring to semiconductors the enormous benefits that open-source already provides to software: transparency, reuse and collaboration.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1781-web.png"},"website":"https://lowrisc.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1782,"name":"ACTIA Group","member_since":"2026-01-21","renewal_date":"2027-02-01","description":{"long":"Founded in 1986, ACTIA Group is a mid-sized, family-owned international company designing and manufacturing electronic systems for demanding sectors including mobility, aerospace, space and energy. ACTIA supports its customers throughout the full product lifecycle, from design to production and services. The Group delivers robust, high-performance and competitive solutions, with strong industrial capabilities and supply chain expertise. Its organization enables responsiveness and execution across international markets, making ACTIA a reliable partner for complex electronic programs."},"logos":{"print":"https://membership.eclipse.org/organization/images/1782-print.eps","web":"https://membership.eclipse.org/organization/images/1782-web.png"},"website":"https://www.actia.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1784,"name":"AINekko, Co.","member_since":"2026-02-24","renewal_date":"2027-03-01","description":{"long":"Ainekko develops RISC-V–based compute platforms for AI applications on the edge and contributes to the open hardware ecosystem through collaboration with the OpenHW Group and the broader RISC-V community."},"logos":{"print":"https://membership.eclipse.org/organization/images/1784-print.eps","web":"https://membership.eclipse.org/organization/images/1784-web.png"},"website":"https://nekko.ai/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1785,"name":"Appraid-tech","member_since":"2026-02-24","renewal_date":"2027-03-01","description":{"long":""},"logos":{"print":"https://membership.eclipse.org/organization/images/1785-print.eps","web":"https://membership.eclipse.org/organization/images/1785-web.png"},"website":"https://www.appraid-tech.com/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1786,"name":"Applied Intuition Inc.","member_since":"2026-02-25","renewal_date":"2027-03-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1788,"name":"42dot Inc.","member_since":"2026-03-09","renewal_date":"2027-03-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1789,"name":"Beijing Academy of Artificial Intelligence (BAAI)","member_since":"2026-03-10","renewal_date":"2027-03-01","description":{"long":"Beijing Academy of Artificial Intelligence(BAAI) is a non-profit new research and development institution established in November 2018. It is committed to becoming a leader in artificial intelligence innovation, creating the best academic and technological innovation ecosystem globally, tackling the most fundamental and critical problems, and serving as the source of academic ideas, basic theories, top talents, enterprise innovation, and development policies for artificial intelligence worldwide, thereby promoting sustainable development for humanity, the environment, and intelligence."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1789-web.png"},"website":"https://www.baai.ac.cn","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1790,"name":"Open Culture Foundation","member_since":"2026-04-09","renewal_date":"2027-04-01","description":{"long":"Open Culture Foundation is a non-profit organization. Through promoting open technology and cross-field collaboration, we continue to connect tech communities and other public and private entities in Taiwan. By doing so, we work to promote open co-creation and protect digital rights, and thereby support a more transparent and inclusive digital civil society.\nSince 2014, we have functioned as a legal entity and supported over 30 open technology communities in Taiwan. Throughout this process, we have not only continued to promote the idea of open technology, we have also become involved in policy advocacy and spoken up for the public's digital rights."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1790-web.png"},"website":"https://ocf.tw/en/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1791,"name":"Mosaic SoC","member_since":"2026-04-14","renewal_date":"2027-04-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1792,"name":"Fundación para la Transparencia del Software","member_since":"2026-04-16","renewal_date":"2027-04-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1793,"name":"AUTOSOL, LP","member_since":"2026-05-07","renewal_date":"2027-05-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true}] \ No newline at end of file +[{"organization_id":656,"name":"IBM","member_since":"2002-02-21","renewal_date":"2027-01-01","description":{"long":"IBM and Eclipse\r\n
    \r\nIBM is proud to be among the founders of the Eclipse project. Beginning in 2001, both IBM and Rational Software were founding members of the Eclipse consortium and the not for profit Eclipse Foundation. Rational Software was acquired by IBM in 2003, and today IBM Rational continues as a Strategic Member of the Eclipse Foundation.\r\n

    \r\nEclipse continues to be core to dozens of IBM offerings from Rational, WebSphere, Lotus, Tivoli, and Information Management. IBM Rational software provides an Eclipse-based software development platform that improves the speed, quality, and predictability of software projects. This full life-cycle solution combines software engineering best practices, market-leading tools, and services.

    \r\n\r\nThe Rational Software Delivery Platform\r\n
    \r\nThe Rational Software Delivery Platform helps align all aspects of development and engineering operations with business needs. This highly collaborative environment supports IT as well as systems engineering efforts, and spans the entire project lifecycle with a complete, integrated set of products, services, and best practices.\r\n

    \r\nA key component of the Rational portfolio is Jazz, a technology platform for collaborative software delivery. Uniquely attuned to global and distributed teams, the Jazz platform is designed to transform how people work together to build software -- making software delivery more collaborative, productive, and transparent.\r\n

    \r\nThe IBM Rational Software Development Platform is the industry\\'s most complete, open, standards-based software development environment, and it enables our clients to more easily govern their software and systems development and delivery. Ninety-three of the Fortune Top 100 companies use Rational software.\r\n

    \r\nAdditional information is available at ibm.com/rational"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/656-web.gif"},"website":"https://www.ibm.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"},{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"},{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":665,"name":"SAP SE","member_since":"2004-01-01","renewal_date":"2027-02-01","description":{"long":"SAP has a rich history of innovation and growth that has made us the recognized leader in providing collaborative business solutions for all types of industries in every major market. \\r\\n\\r\\nAs a market leader in enterprise application and digital transformation software, SAP helps companies of all sizes and industries run better. From back office to boardroom, warehouse to storefront, desktop to mobile devices, SAP empowers people and organizations to work together more efficiently by utilizing cloud, analytics, machine learning, Big Data, IoT and other insights more effectively to stay ahead of the competition. SAP applications and open cloud platform services enable more than 296,000 customers in 190 countries to operate profitably, adapt continuously, and grow sustainably.\\r\\n\\r\\nSAP has been a strategic member of the Eclipse Foundation since its inception."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/665-web.png"},"website":"https://www.sap.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Platinum Member","level":"WGPLM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":682,"name":"Ericsson AB","member_since":"2004-01-14","renewal_date":"2027-02-01","description":{"long":"At Ericsson, we strive to connect everyone, wherever they may be. Because by being connected, people can take part in the emerging global collaboration that is the Networked Society - a society in which every person and every industry is empowered to reach their full potential.\\r\\nOur services, software and infrastructure - especially in mobility, broadband and the cloud - are enabling the communications industry and other sectors to do better business, increase efficiency, improve their users\\' experience and capture new opportunities.\\r\\nBy enabling the Networked Society, we make a real difference to people\\'s lives, and the world we live in.\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/682-web.png"},"website":"https://www.ericsson.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":685,"name":"Fujitsu Limited","member_since":"2004-04-28","renewal_date":"2027-04-01","description":{"long":"We provide software and services to help companies continuously visualize and optimize their business processes and applications to improve and innovate while creating leaner, more efficient operations. With market conditions changing rapidly, organizations need to be equipped to iteratively develop, deploy, and optimize business processes and applications to meet these business demands - without compromising on business governance."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/685-web.png"},"website":"https://www.fujitsu.com/global/","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Enterprise Member","level":"WGDSA","working_group":"adoptium"},{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":687,"name":"Genuitec, LLC","member_since":"2008-08-31","renewal_date":"2027-01-01","description":{"long":"Genuitec's products enable developers to build anything from anywhere with anyone.\n

    \nMyEclipse, our flagship professional IDE, is the world-wide leader in its class for enterprise Java and web development. Premium toolset. Fair pricing.\n

    \nCodeTogether, our cross-IDE live sharing system, enables users of Eclipse, VS Code, IntelliJ, and the IDEs based on those, to code together collaboratively using all the tools they prefer.\n

    \nDevStyle with Darkest Dark makes millions of Eclipse installations look their very best, in dark or light themes, with stunning custom icons. Free in the marketplace."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/687-web.png"},"website":"https://genuitec.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":690,"name":"EclipseSource","member_since":"2007-03-01","renewal_date":"2027-03-01","description":{"long":"EclipseSource has well over a decade of experience in designing, developing and enhancing tools for a variety of domains and based on all major technology platforms. Whether it is a classic IDE for software engineering, a modeling tool for your domain experts or a domain-specific solution for engineers, whether the tool is a web-based, a desktop-based application, a tool based on Eclipse Theia or a plugin for Eclipse, EclipseSource can support you in implementing the best possible solution for your use case. We provide a complete range of services including conception, evaluation, training, support, and consulting/implementation all with a special focus on framework adoption, creation, and (long-term) maintenance. EclipseSource is a major contributor to a large number of open source projects inside and outside the Eclipse ecosystem. EclipseSource is distributed over multiple locations in Europe and serves a truly global customer base from various domains, ranging from Fortune 100 corporations to individual developers"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/690-web.png"},"website":"https://eclipsesource.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"","level":"WGSM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":721,"name":"Oracle","member_since":"2004-01-27","renewal_date":"2027-02-01","description":{"long":"Oracle\\'s business is information how to manage it, use it, share it, protect it. The world\\'s largest enterprise software company, Oracle is the only vendor to offer solutions for every tier of your business-database, middleware, business intelligence, business applications, and collaboration. With Oracle, you get information that helps you measure results, improve business processes, and communicate a single truth to your constituents.\\r\\n\\r\\nOracle\\'s next-generation enterprise computing platform Fusion is being designed to enable incremental adoption of a powerful, flexible, service-oriented IT infrastructure without the disruption associated with a wholesale platform upgrade. This portfolio is built on powerful Fusion design principles, standardizing the priorities and practices of your enterprise computing strategy-saving you significant time and money."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/721-web.gif"},"website":"https://www.oracle.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":731,"name":"Red Hat, LLC.","member_since":"2005-01-26","renewal_date":"2027-03-01","description":{"long":"Red Hat is the open hybrid cloud technology leader, delivering a trusted, consistent and comprehensive foundation for transformative IT innovation and AI applications. Its portfolio of cloud, developer, AI, Linux, automation and application platform technologies enables any application, anywhere—from the datacenter to the edge. As the world's leading provider of enterprise open source software solutions, Red Hat invests in open ecosystems and communities to solve tomorrow's IT challenges. Red Hat helps its partners and customers build, connect, automate, secure and manage their IT environments, supported by consulting services and award-winning training and certification offerings."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/731-web.png"},"website":"https://www.redhat.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Innovator Member","level":"WGPAA","working_group":"internet-things-iot"},{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"df911e0adcad1a1c51df","description":"","level":"WGPL","working_group":"asciidoc"},{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"},{"document_id":"efcdef5b284754c43de2","description":"Strategic Member","level":"WGSD","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":742,"name":"Thales","member_since":"2009-08-28","renewal_date":"2027-04-01","description":{"long":"Thales is a world leader in mission-critical information systems for defense and security, aerospace and transportation."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/742-web.jpg"},"website":"https://www.thalesgroup.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Strategic Member","level":"WGSD","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":758,"name":"Fraunhofer-Gesellschaft","member_since":"2004-01-01","renewal_date":"2027-02-01","description":{"long":"

    The Fraunhofer-Gesellschaft, headquartered in Germany, is the worlds leading applied research organization. With its focus on developing key technologies that are vital for the future and enabling the commercial exploitation of this work by business and industry, Fraunhofer plays a central role in the innovation process. As a pioneer and catalyst for groundbreaking developments and scientific excellence, Fraunhofer helps shape society now and in the future. Founded in 1949, the Fraunhofer-Gesellschaft currently operates 75 institutes and research institutions throughout Germany. The majority of the organizations 29,000 employees are qualified scientists and engineers, who work with an annual research budget of 2.8 billion euros. Of this sum, 2.4 billion euros are generated through contract research.

    \\r\\n

    For several Fraunhofer institutes, open source plays a vital role in many research areas:

    \\r\\n

    The Fraunhofer Institute for Open Communication Systems FOKUS offers research services ranging from requirements analysis to consulting, feasibility studies, technology development right up to prototypes and pilots in the business segments Digital Public Services, Future Applications and Media, Quality Engineering, Smart Mobility, Software-based Networks, Networked Security, Visual Computing und Analytics. Fraunhofer FOKUS, for example provides the open source simulation environment Eclipse MOSAIC for testing mobility scenarios. In addition, the institute has contributed an IoT-Testware to Eclipse and is interested in AI, Cloud and Edge activities.

    \\r\\n\\r\\n

    The Fraunhofer Institute for Intelligent Analysis and Information Systems IAIS is one of the leading scientific institutes in Artificial Intelligence, Machine Learning, and Big Data in Germany and Europe. With its more than 300 employees, the institute supports companies in the optimization of products, services, processes and structures and development of new digital business models.

    \\r\\n\\r\\n

    The Fraunhofer Institute for Experimental Software Engineering IESE supports the digitization of services, systems, and the development of digital ecosystems. Dedicated to open-source software, we create solutions for virtual engineering, safe systems, and Industry 4.0.

    \\r\\n\\r\\n

    The Fraunhofer Institute for Software and Systems Engineering ISST focuses on designing and developing data spaces that enable sovereign, secure and controllable data sharing across company boundaries. Therefore, Fraunhofer ISST offers technical design, implementation of system components and consultancy services throughout the entire development process.

    \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/758-web.png"},"website":null,"levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"},{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":760,"name":"Object Management Group, Inc.","member_since":"2004-01-01","renewal_date":"2027-01-01","description":{"long":"OMG Task Forces develop enterprise integration standards for a wide range of technologies and an even wider range of industries. OMG\\'s modeling standards enable powerful visual design, execution and maintenance of software and other processes. For more information, visit www.omg.org. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/760-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":800,"name":"STMicroelectronics International N.V.","member_since":"2020-01-01","renewal_date":"2027-01-01","description":{"long":"At ST, we are 48,000 creators and makers of semiconductor technologies mastering the semiconductor supply chain with state-of-the-art manufacturing facilities. An independent device manufacturer, we work with more than 200,000 customers and thousands of partners to design and build products, solutions, and ecosystems that address their challenges and opportunities, and the need to support a more sustainable world. Our technologies enable smarter mobility, more efficient power and energy management, and the wide-scale deployment of the Internet of Things and 5G technology. ST is committed to becoming carbon neutral by 2027. Further information can be found at www.st.com."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/800-web.png"},"website":"https://st.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":816,"name":"Vector Informatik GmbH","member_since":"2006-05-12","renewal_date":"2027-05-01","description":{"long":"

    \nVector provides tools, software components and engineering services for the networking of electronic systems in the automobile and related industries.\n

    The ECU development is supported with tools for the design, test, calibration and diagnostics as well as with software components and development services.

    "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/816-web.png"},"website":"https://www.vector.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Platinum Member","level":"WGPLM","working_group":"eclipse-ide"},{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":823,"name":"ARM Limited","member_since":"2006-08-01","renewal_date":"2027-04-01","description":{"long":"Arm designs the technology that lies at the heart of advanced digital products, from wireless, networking and consumer entertainment solutions to imaging, automotive, security and storage devices.\\r\\n
    \\r\\nArm\\'s comprehensive product offering includes 16/32-bit RISC microprocessors, data engines, 3D processors, digital libraries, embedded memories, peripherals, software and development tools, as well as analog functions and high-speed connectivity products.\\r\\n
    \\r\\nCombined with the company\\'s broad Partner community, they provide a total system solution that offers a fast, reliable path to market for leading electronics companies. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/823-web.png"},"website":"https://www.arm.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":848,"name":"Advanced Micro Devices (AMD)","member_since":"2007-02-27","renewal_date":"2026-07-01","description":{"long":"Advanced Micro Devices, Inc. (NYSE: AMD) is a global leading provider of processors, chipsets and graphics products. To ensure that these products enable solutions for customers, AMD works with the software community, invests in advancements in the software ecosystem and develops tools and libraries to assist in software development. For more information on AMD's software product, efforts and guidance on software development, visit AMD Developer Central at http://developer.amd.com"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/848-web.jpg"},"website":"https://www.amd.com/en/developer.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"}],"is_active_member":true},{"organization_id":863,"name":"OBEO","member_since":"2007-05-29","renewal_date":"2026-06-01","description":{"long":"Obeo is a software provider, specialized in the model driven approach and a key player of the Eclipse platform. It is an actor of the Open Source ecosystem and a strategic member of the Eclipse Foundation; Obeo is one of the major Eclipse contributors, ranking up as one of the top contributing companies every year since it became a member of the Eclipse Foundation.\\r\\n\\r\\nObeo\\'s primary concerns are to provide open technologies allowing users to master the complexity of systems.\\r\\n\\r\\nIts product range include: Sirius (Graphical Designers), Acceleo (code generator), Obeo Designer (custom graphical modeling environment), collaborative add-ons for Eclipse Capella, Obeo SmartEA (Enterprise Architecture), consulting (training, expertise and coaching), and Eclipse Modeling as a foundation stack of any modeling environment.\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/863-web.png"},"website":"https://www.obeosoft.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":890,"name":"BlackBerry Limited ","member_since":"2007-12-04","renewal_date":"2026-12-01","description":{"long":"QNX Software Systems Limited, a subsidiary of BlackBerry Limited, is a leading provider of operating systems, middleware, professional services, and Eclipse-based development tools for connected embedded systems. Global leaders such as Audi, Siemens, General Electric, Cisco, and Lockheed Martin depend on QNX technology for their in-car electronics, medical devices, industrial automation systems, network routers, and other mission- or life-critical applications. Visit www.qnx.com and follow @QNX_News on Twitter. For updates on the company\\'s automotive work, follow @QNX_Auto and visit qnxauto.blogspot.com."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/890-web.png"},"website":"https://blackberry.qnx.com/en","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":895,"name":"Siemens AG","member_since":"2008-01-16","renewal_date":"2027-02-01","description":{"long":"Siemens is a global powerhouse focusing on the areas of electrification, automation and digitalization. One of the worlds largest producers of energy-efficient, resource-saving technologies, Siemens is a leading supplier of systems for power generation and transmission as well as medical diagnosis. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/895-web.gif"},"website":"https://www.siemens.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"},{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":937,"name":"CEA LIST","member_since":"2008-09-18","renewal_date":"2027-01-01","description":{"long":"List, expert on digital systems
    \\r\\n
    \\r\\nBased in Saclay (Paris region, France), List is a public research institute specialized in digital systems design. Its main mission is based on achieving excellence technological development on behalf of industrial partners for value creation.
    \\r\\n
    \\r\\n100 industrial collaborations per year
    \\r\\n
    \\r\\nList institute counts more than 700 partners and every year more than a 100 partnership activities are being conducted with French and foreign industrial companies on applied research projects in four main topics:\\r\\n
      \\r\\n
    • Advanced Manufacturing
    • \\r\\n
    • Embedded systems
    • \\r\\n
    • Ambient intelligence
    • \\r\\n
    • Health ionizing radiations
    • \\r\\n
    \\r\\nLabeled as Carnot Institute , List invests every year 25% of its budget into scientific resourcing actions in order to identify better tomorrows technological breakthroughs.
    \\r\\n
    \\r\\nCEA Tech as CEA (Commissariat a l\\'energie atomique et aux energies alternatives) Technological Research Division, gathers three specialised technological research institutes among which List institute specialised on digital systems.
    \\r\\n
    \\r\\nAt a world class state-of-the-art
    \\r\\n
    \\r\\nOur activity is based on three main pillars\\r\\n
      \\r\\n
    • Scientific excellence
    • \\r\\n\\r\\nList research engineers dedicate a 100% of their time to R&D activities and publish their results into international leading conferences and scientific journals. Keeping a strong link with academic research, they base their research on world-wide state of the art.\\r\\n\\r\\n
    • The Culture of Industry
    • \\r\\n\\r\\nOur research teams are enlightened and motivated by a results-driven culture of projects, fixing themselves clear objectives to reach within committed deadlines and budgets. Each project launched by List Institute is fully assigned to permanent and suited human resources. The project management is based on a precise calendar, identified milestones and a clear description of deliverables.
      \\r\\n\\r\\nResearch results confidentiality and intellectual property (patents) are defined by the parties in the collaboration agreement.\\r\\n\\r\\n
    • Opening to the world
    • \\r\\n\\r\\nList Institute is fully integrated into a local and national particularly dynamic ecosystem through strategic academic, institutional and industrial partnerships. In order to maintain the best level internationally in its fields of activity List institute is also involved in more than 200 European collaborative projects, collaborates with leading foreign academic laboratories and conducts research activities at an international level, especially in the USA."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/937-web.png"},"website":"https://list.cea.fr/en/","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"ecd63e75a561bffe2ffc","description":"Strategic Member","level":"WGSD","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":954,"name":"Business Systems Integration AG","member_since":"2009-03-26","renewal_date":"2027-04-01","description":{"long":"With its BSI Customer Suite, the Swiss software company BSI provides a comprehensive platform for the digital transformation of customer relationships. It offers everything needed for an outstanding customer experience in the retail, banking, insurance and energy & utility industries. At the core of the innovation is the company’s many years of industry experience. Founded in Baden, Switzerland, in 1996, BSI has about 400 employees and 7 additional offices in Germany and Switzerland. BSI’s customers include companies and organizations such as ADAC, Signal Iduna and HDI and other market-leading companies throughout Europe. Visit BSI"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/954-web.png"},"website":"https://www.bsi-software.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":968,"name":"Eurotech","member_since":"2009-12-10","renewal_date":"2027-01-01","description":{"long":"

      Eurotech integrates hardware, software, solutions, and expertise to deliver embedded computing platforms, sophisticated systems and cloud-based services to leading OEMs, system integrators, and enterprise customers for successful, efficient, and speedy deployment of their products and services.

      \n\n

      Eurotech simplifies pervasive computing, allowing our customers to focus on their core competencies, the products and services only they can deliver, while Eurotech lays the embedded computing foundation to bring those offerings to market as quickly as possible. (1) Minimalist computing, drawing on decades of experience in low power design, miniaturization of platforms, and simplification of application development through modular middleware and toolsets, allows our customers to create the most efficient products and services possible. (2) With strengths in wireless services and communications protocols, we deliver the integrated and connected solutions our customers need to simplify the development and deployment of their products and services, even through the cloud. (3) Combining pervasive technology excellence with domain expertise allows Eurotech to meet the pervasive computing needs of five key market segments including healthcare, security, transportation, energy, and industrial. (4) As a trusted business associate to both our customers and our partners, we are committed to the mutual success of all companies in the value chain for networked solutions.

      \n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/968-web.png"},"website":"https://www.eurotech.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Leader Member","level":"WGLM","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":977,"name":"FZI Forschungszentrum Informatik","member_since":"2010-04-12","renewal_date":"2027-04-01","description":{"long":"The FZI Research Centre for Information Technology is an interdisciplinary non-profit research organization, based in Karlsruhe, Germany, whose mission is to facilitate technology transfer of innovative IT solutions and to provide a bridge between academia and industry. FZI offers its customers a unique interdisciplinary environment that fosters joint research among diverse fields of Computer Science, Mechanical and Electrical Engineering, and Economics. \n\nFZI has been a great success story for 25 years now, and using its extensive network of contacts both in the academic and the industrial world, it has been an important catalyst for the development of IT in the Karlsruhe region. \n\nToday, FZI has over 150 employees, mostly young scientists with outstanding experience in both research projects and professional consulting activities.\n\nFZI is a major promoter of Open Source, having among its employees contributors to dozens of open source projects, many of which targeting the Eclipse platform.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/977-web.png"},"website":"https://www.fzi.de","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":979,"name":"Robert Bosch GmbH","member_since":"2010-04-27","renewal_date":"2027-01-01","description":{"long":"The Bosch Group is a global supplier of technology and services. Its operations are divided into four business sectors: Mobility Solutions, Industrial Technology, Consumer Goods, and Energy and Building Technology. Bosch offers innovative solutions for smart homes, Industry 4.0, and connected mobility. Bosch is pursuing a vision of mobility that is sustainable, safe, and exciting, as well as an open approach to the Software Defined Vehicle technology stack of the future in conjunction with its subsidiary ETAS GmbH. The Bosch Group comprises roughly 440 companies in about 60 countries, employing some 76,100 associates in research and development, around half of which are software engineers."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/979-web.png"},"website":"https://bosch.com","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Leader Member","level":"WGLM","working_group":"internet-things-iot"},{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"},{"document_id":"aea0514f5cc2d0407ffd","description":"Driver Member","level":"WGPAE","working_group":"openpass"},{"document_id":"f348c2873ca8ed8e9eca","description":"Supporting Member","level":"WGSM","working_group":"oniro"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"},{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":989,"name":"Protos Software GmbH","member_since":"2010-06-23","renewal_date":"2026-07-01","description":{"long":"Protos is a service company that specialized in the development of model-driven, domain-specific tools and applications for Embedded Systems.\\r\\n\\r\\nWe develop tools and applications for our customers and support them with training, consulting and coaching. Most of our projects are based on Eclipse Open Source Tools."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/989-web.png"},"website":"https://protos.de","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":990,"name":"Sigasi","member_since":"2010-06-24","renewal_date":"2026-07-01","description":{"long":"Sigasi allows FPGA and ASIC designers in the medical, telecom, automotive, defense, and aerospace worlds to achieve their full potential with a powerful Integrated Development Environment (IDE).\n\nSigasi assists design engineers in writing RTL with a mix of VHDL, Verilog, and SystemVerilog, giving them everything from basic editing to advanced features like autocomplete, code navigation, and linting. Most importantly, Sigasi gives hardware designers real-time feedback.\n\nMoreover, Sigasi integrates with existing workflows, including CI/CD checking, allowing teams to safeguard entire code repositories. This is particularly valuable for ASIC design and optimizing hand-off to verification teams."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/990-web.png"},"website":"https://www.sigasi.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":998,"name":"FUNDACIÓN TECNALIA RESEARCH & INNOVATION","member_since":"2010-09-24","renewal_date":"2027-04-01","description":{"long":"

      TECNALIA is the largest center of applied research and technological development in Spain, a benchmark in Europe and a member of the Basque Research and Technology Alliance. We collaborate with companies and institutions to improve their competitiveness, people’s quality of life and achieve sustainable growth. We do it thanks to people who are passionate about technology and committed to building a better society.

      \n

      Our Mission: To transform technological research into prosperity.

      \n

      Our Vision: To be agents of transformation of companies and society for their adaptation to the challenges of a changing future.

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/998-web.png"},"website":"https://www.tecnalia.com/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Supporter Member","level":"WGSM","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1006,"name":"Yatta Solutions GmbH","member_since":"2010-11-29","renewal_date":"2026-12-01","description":{"long":"Yatta is all about software development, engineering and evolution. We started as a developer tool company, transformed into a software vendor and now help build B2B ecosystems for digital products.\n

      \nWe are open-source project lead of the Eclipse Marketplace Client, package maintainer of the Eclipse IDE for Java Developers, and member of the Eclipse IDE working group. We commit and contribute to various other open-source projects as well.\n

      \nOur goal is to keep and sustain Eclipse as an open ecosystem. That's why we have launched the Yatta Checkout for Eclipse."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1006-web.png"},"website":"https://yatta.de/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1009,"name":"BMW Group","member_since":"2011-01-01","renewal_date":"2027-01-01","description":{"long":"BMW Group is now Eclipse member.\n

      \nThe BMW Group is an automobile manufacturer. With its three brands, BMW, MINI and Rolls-Royce Motor Cars, the BMW Group is focusing on the premium sector of the international automobile market. In addition the BMW Group is also a manufacturer of motorcycles and a provider of financial services.\nSoftware plays an important role in modern cars and is one of the main drivers of innovation in the automobile industry. The Eclipse technology is used by BMW in various forms for the development of in-car electric/electronic (E/E) systems and its accompanying development tasks.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1009-web.png"},"website":"https://www.bmw.com/en/index.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"aea0514f5cc2d0407ffd","description":"Driver Member","level":"WGPAE","working_group":"openpass"},{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1042,"name":"Virtual Vehicle Research GmbH","member_since":"2012-02-03","renewal_date":"2027-02-01","description":{"long":"Virtual Vehicle Research GmbH (ViF) is a holding company of the COMET K2 research program \\\"K2 Digital-Mobility\\\" an international institution in the field of application-oriented vehicle development."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1042-web.jpg"},"website":"https://www.virtual-vehicle.at/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1069,"name":"Renesas Electronics Corporation","member_since":"2012-11-09","renewal_date":"2026-11-01","description":{"long":"Renesas Electronics Corporation, headquartered in Japan, delivers trusted embedded design innovation with complete semiconductor solutions that enable billions of connected, intelligent devices to enhance the way people work and livesecurely and safely.\\r\\n\\r\\nA global leader in microcontrollers, analog, power and SoC products, Renesas provides the expertise, quality, and comprehensive solutions for a broad range of Automotive, Industrial, Home Electronics (HE), Office Automation (OA) and Information Communication Technology (ICT) applications to help shape a limitless future.\\r\\n\\r\\nRenesas Electronics is one of the leading supplier for the global automotive industry and number one supplier of automotive microcontrollers (MCUs) worldwide with advanced semiconductor solutions, including system-on-chip (SoC). \\r\\n\\r\\nWith Renesas autonomyTM, an open, innovative, and trusted platform for assisted and automated driving, Renesas Electronics gives customers the choice to decide the future of driving will look like.\\r\\n\\r\\nRenesas Electronics is dedicated to support big ideas both locally and globally with its subsidiaries in 20 countries worldwide. More information is available at www.renesas.com."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1069-web.png"},"website":"https://www.renesas.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"},{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1077,"name":"University of Skovde","member_since":"2013-02-28","renewal_date":"2027-02-01","description":{"long":"The University of Skovde is one of the most specialised universities in Sweden and our research is focused on the development and use of advanced information technology systems and models. Areas of expertise include organisational and technological aspects of the ICT area. Over a number of years research has addressed various aspects of openness. We have significant experience with research and practice related to different stakeholder roles (including providers, developers and users) related to Open Source and Open Standards. Previous activities include involvement as partner and leader in several international and national research projects. In collaboration with leading academic partners we conducted rigorous research in the EU FP6 CALIBRE project (2004-2006), which involved extensive interaction with European industry and presented a roadmap for future research on the Open Source phenomenon. As partners in the CALIBRE-project, the ITEA-project COSI and the ITEA2-project OPEES, we have experience of international collaboration, and close collaboration with many leading researchers and practitioners in areas related to the Open Source phenomenon. Current activities include research on various aspects of openness impacting on long-term sustainability of software systems with associated digital assets. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1077-web.jpg"},"website":"https://www.his.se/en","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1083,"name":"Robotron Datenbank-Software GmbH","member_since":"2013-06-01","renewal_date":"2026-06-01","description":{"long":"Robotron is an innovative IT service provider specializing in the efficient management and analysis of large volumes of data. We support customers in the energy sector, industry and public administration with practical software solutions that optimize business processes and deliver measurable value across the value chain. Our portfolio is complemented by comprehensive consulting, project and operational services – making us a reliable partner who understands both technologies and industry-specific processes."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1083-web.jpg"},"website":"https://www.robotron.eu","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1090,"name":"Open Source Automation Development Lab (OSADL)","member_since":"2022-07-27","renewal_date":"2027-04-01","description":{"long":"The Open Source Automation Development Lab (OSADL) eG is a community for Open Source software in industry and delivers everything a company needs to successfully use Open Source software and especially Linux in industrial products and generally in embedded systems in an efficient and license compliant way. \n\nOSADL is a registered cooperative and accepts members from all over the world. The economical advantage of an OSADL membership is based on the principle of OSADL’s business model: Develop once for the use of many. \n\nMore information at: https://www.osadl.org"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1090-web.png"},"website":"https://www.osadl.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1105,"name":"Lablicate GmbH","member_since":"2013-12-01","renewal_date":"2026-12-01","description":{"long":"Lablicate GmbH is the company behind OpenChrom. Our expertise is software in general and Eclipse technology in special in combination with knowledge of various techniques used in analytical chemistry and related areas. The combination of IT- and Science Know-How is our strength. We are experienced using the benefits of both world."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1105-web.png"},"website":"https://www.lablicate.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1106,"name":"AMIQ EDA","member_since":"2013-12-09","renewal_date":"2026-12-01","description":{"long":"AMIQ EDA provides software tools that enable hardware design and verification engineers to increase the speed and quality of new code development, simplify legacy code maintenance, accelerate language and methodology learning, and improve source code reliability."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1106-web.jpg"},"website":"https://www.amiq.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1122,"name":"HiveMQ GmbH","member_since":"2014-05-06","renewal_date":"2027-05-01","description":{"long":"HiveMQ helps companies connect devices to the Internet. Our HiveMQ MQTT platform makes it possible to move data from device to cloud in a secure, reliable and scalable manner. Over 130 customers, including many Fortune 500 companies, rely on HiveMQ in production for mission critical use cases like connected cars, transportation, logistics, Industry 4.0 and connected IoT products. Visit hivemq.com for more details."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1122-web.png"},"website":"https://www.hivemq.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Innovator Member","level":"WGPAA","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1125,"name":"Kichwa Coders Canada Inc.","member_since":"2014-05-14","renewal_date":"2027-05-01","description":{"long":"Kichwa Coders is a software consultancy specialising in Eclipse open source software for scientific and embedded applications. We help companies adopt and make the most out of open source software."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1125-web.png"},"website":"https://www.kichwacoders.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"","level":"WGSM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1134,"name":"Mercedes-Benz Tech Innovation GmbH","member_since":"2014-06-18","renewal_date":"2027-01-01","description":{"long":"We develop IT for tomorrow's mobility: We are a fully owned subsidiary of Mercedes-Benz Group AG. As an equal IT partner, we work within the Mercedes-Benz Group AG to shape the digital path to future mobility."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1134-web.png"},"website":"https://www.mercedes-benz-techinnovation.com/","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"aea0514f5cc2d0407ffd","description":"Driver Member","level":"WGPAE","working_group":"openpass"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1135,"name":"Canonical Group Limited","member_since":"2014-06-12","renewal_date":"2026-06-01","description":{"long":"

      Canonical is the company behind Ubuntu, the leading OS for container, cloud, scale-out and hyperscale computing. 65% of large-scale OpenStack deployments are on Ubuntu, using both KVM and the pure-container LXD hypervisor for the worlds fastest private clouds. Canonical provides enterprise support and services for commercial users of Ubuntu.

      \\r\\n\\r\\n

      Canonical leads the development of Juju, the model-driven operations system, and MAAS (Metal-as-a-Service), which creates a physical server cloud and IPAM for amazing data centre operational efficiency. Established in 2004, Canonical is a privately held company.

      \\r\\n\\r\\n

      Canonical leads the development of the snap universal Linux packaging system for secure, transactional device updates and app stores. Ubuntu Core is an all-snap OS, perfect for devices and appliances. Established in 2004, Canonical is a privately held company.

      \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1135-web.png"},"website":"https://www.ubuntu.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Enterprise Member","level":"WGDSA","working_group":"adoptium"},{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1138,"name":"Universite Grenoble Alpes (UGA)","member_since":"2014-07-03","renewal_date":"2026-07-01","description":{"long":"As the world is becoming more and more competitive, our institution aims to better respond to the challenges the world poses universities today and in the future, and to be more visible and attractive internationally.\\r\\n\\r\\nThe Universit Grenoble Alpes already features in the top 100 and top 200 universities in major international rankings (Reuters, Shanghai, Times Higher Education and QS for example) for some of its scientific fields. The UGA rivals the best universities in the world thanks to the strength of its research and the numerous educational innovations it has implemented."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1138-web.png"},"website":"https://www.univ-grenoble-alpes.fr/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1144,"name":"DB Systel GmbH","member_since":"2014-08-01","renewal_date":"2027-03-01","description":{"long":"

      \\r\\nDB Group offers globally mobility and logistical services and operates in over 130 countries world-wide. Every day, more than 300,000 employees, of which about 195,000 are located in Germany, are committed to ensuring that customers are provided with mobility and logistical services and that the related rail, road, ocean and air traffic networks are operated and controlled efficiently.\\r\\n

      \\r\\n

      \\r\\nThe companys core business is the railway in Germany with more than 5,5 million customers every day in the passenger transport segment, and about 596 thousand tons of freight shipped via rail. More than 1.8 million customers travel via DB buses in Germany every day. Deutsche Bahn operates more than 40,000 train runs daily on its more than 33,300 kilometer-long, modern rail network, which is also open to competition. The number of train stations is 5.681.\\r\\n

      \\r\\n

      \\r\\nFrom electronic signal boxes to online ticketing and computerized route planning \\r\\noperating today\\'s highly complex mobility and traffic networks is simply unimaginable\\r\\nwithout information and communication technology (ICT). DB Systel, a wholly owned subsidiary of the DB Group, is the digitalisation partner for all Deutsche Bahn companies. As an integrated and value-adding company within the DB Group, DB Systel offers a comprehensive range of customised solutions and services that meets the highest IT standards and picks up on the latest trends. It does so by incorporating its extensive railway and IT expertise and, as a long-term vendor-neutral partner, by pursuing the Groups common objective.\\r\\n

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1144-web.png"},"website":"https://www.dbsystel.de/dbsystel","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1147,"name":"Mueller-BBM VibroAkustik Systeme GmbH","member_since":"2014-10-01","renewal_date":"2026-10-01","description":{"long":"As one of the world\\'s leading suppliers of vibroacoustic measurement technology, Mueller-BBM VibroAkustik Systeme is focussed on the acquisition, analysis, evaluation and management of dynamic data. \nOur tight partnership with the various industries as well as our recognized expertise in acoustics and vibration results in innovative solutions and establishes us as a strong partner for your noise, vibration and harshness (NVH) measurement and analysis requirements. Our PAK system seamlessly integrates into laboratory, production and field environments."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1147-web.png"},"website":"https://www.mbbm-vas.com/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1156,"name":"Neuron Engineering Tools GmbH","member_since":"2015-01-08","renewal_date":"2027-01-01","description":{"long":"Neuron Engineering Tools GmbH, with locations in Austria, Germany and Hungary, has been developing software tools and platforms for industrial automation since 1987. Key solutions include the IEC 61131-3 programming system of the Neuron Engineer series, the portable runtime system RTS (scalable from microcontrollers to multi-core IPCs), and the documentation tool logi.DOC. Over 30,000 engineers worldwide use Neuron software to automate systems such as power plants, steel mills, machines, and more — creating, testing, and managing efficient, high-quality solutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1156-web.png"},"website":"https://www.neuron-automation.eu/en","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1164,"name":"Gradle Inc","member_since":"2015-02-24","renewal_date":"2027-03-01","description":{"long":"Gradle Inc. is the company behind the leading software solution for improving developer productivity called Gradle Enterprise and the popular open-source Java build automation system called Gradle Build Tool.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1164-web.png"},"website":"https://gradle.org","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1166,"name":"Azul Systems, Inc","member_since":"2015-05-07","renewal_date":"2027-05-01","description":{"long":"Azul Systems is the world\\'s only company that is 100% focused on Java and Java runtime technology. We believe that we can help the IoT developers take advantage of the power and productivity of Java by reducing the frictions (licensing costs, field-of-use restrictions) and perceptions (footprint, etc.) gating widespread adoption of the language throughout the IoT.\nAs members of the Eclipse community we are bringing Zulu and Zulu Embedded - our 100% open source JDKs, to the IoT. Our Zulu products are certified builds of OpenJDK and meet the Java SE standards for Java 8, 7 and 6. Each release of Zulu and Zulu Embedded has passed the thousands of tests in OpenJDK Technology Compatibility Kit (TCK) as well as extensive in-house verification suite. Zulu runs on many Linux distros, on Windows and the Mac.\nZulu is a complete Java Development Kit, and Zulu Enterprise provides designers with a choice of storage footprint, bitness (32 or 64-bit configurations), headless or headful, and both development and runtime-only options.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1166-web.jpg"},"website":"https://www.azul.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1194,"name":"TypeFox GmbH","member_since":"2016-02-02","renewal_date":"2027-02-01","description":{"long":"TypeFox is a team of software pioneers building the languages and IDEs that modern engineering teams rely on. We’re the inventors behind open source projects such as Langium, Theia, Sprotty, and Open VSX — technologies that have become the backbone of custom development environments and domain-specific tooling across industries.\n\nWe help projects move from idea to working product with clarity and technical depth. Whether it’s a cloud-ready IDE, a tailored DSL, or a complex graph visualization, we build solutions that adapt to your workflows instead of the other way around. And because our technology base is open source, you benefit from extensible foundations designed for long-term impact."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1194-web.png"},"website":"https://www.typefox.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"d96a8cabd0d04f29dfe6","description":"Participant Member","level":"WGAPS","working_group":"cloud-development-tools"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"f348c2873ca8ed8e9eca","description":"Supporting Member","level":"WGSM","working_group":"oniro"}],"is_active_member":true},{"organization_id":1196,"name":"Microsoft Corp.","member_since":"2016-01-15","renewal_date":"2026-06-01","description":{"long":"At Microsoft, our developer mission is to deliver experiences that empower any developer, building any application, on any OS. And this mission requires us to be open, flexible, and interoperable: to meet developers and development teams where they are, and provide tools, services and platforms that help them take ideas into production. Supporting the Eclipse Foundation enables us to collaborate more closely with the Eclipse community, deliver a great set of tools and services for all development teams, and continuously improve our cloud services, SDKs and tools."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1196-web.png"},"website":"https://www.microsoft.com/","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"},{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"},{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Enterprise Member","level":"WGDSA","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Strategic Member","level":"WGSD","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1208,"name":"Universitat Oberta De Catalunya","member_since":"2016-04-07","renewal_date":"2027-04-01","description":{"long":"

      A state-of-the art technological university with a highly innovative learning model, providing a benchmark for quality in both teaching and R&D. This is the philosophy of the Universitat Oberta de Catalunya (UOC, Open University of Catalonia), created in 1994 as one of the worlds very first completely online higher education establishments and that currently has more than 50,000 students.

      \\r\\n

      The UOCs core goal is to be the university of the knowledge society, promoting innovative education, personalised learning, technological leadership, R&D work on the information society and e-learning and the dissemination of knowledge. The UOC promotes R&D activities via 10 groups linked the Internet Interdisciplinary Institute (IN3), specialising in the study of the networked society and the knowledge economy, network technologies and specific software areas. Over the last five years, the UOC has participated in more than 260 R&D projects, either national or European. What is more, the UOC works to promote knowledge transfer and has, over the last four years, signed more than 1000 agreements to this end. The UOC forms part of more than 30 international networks, including the European University Association (EUA), the International Council for Open and Distance Education (ICDE) and the IMS Global Learning Consortium

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1208-web.png"},"website":"https://www.uoc.edu/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1219,"name":"Fondazione Bruno Kessler","member_since":"2016-10-04","renewal_date":"2026-10-01","description":{"long":"Fondazione Bruno Kessler - FBK - is a private no profit research institution based in Trento, Italy. \\r\\nFBK is divided in several centres and its mission is to develop both knowledge and expertise in the fields of Information and Communication Technology, Microsystems/Microelectronics and Social science, aiming to conduct technology transfer at the local, national and international industrial level. \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1219-web.png"},"website":"https://www.fbk.eu/en/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1220,"name":"Salesforce.com, Inc.","member_since":"2016-10-05","renewal_date":"2027-01-01","description":{"long":"Salesforce is a customer relationship management solution that brings companies and customers together. It\\'s one integrated CRM platform that gives all your departments including marketing, sales, commerce, and service a single, shared view of every customer."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1220-web.png"},"website":"https://opensource.salesforce.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"}],"is_active_member":true},{"organization_id":1221,"name":"Webtide LLC","member_since":"2016-10-10","renewal_date":"2026-10-01","description":{"long":"Webtide was founded with one goal in mind: to provide the very best service and support for developer teams of all sizes who want to work with Eclipse Jetty and CometD. Whether your project is small or large, weve worked with companies around the world to make sure that their Jetty and CometD projects are a success.\\r\\n\\r\\nUnlike some other software companies, Webtides focus is on service, not on growth we value stability over size. We dont over-promise or under-deliver; our support is terrific and our products do just what they say theyll do. We have worked with some of the biggest names in technology and have a portfolio of satisfied customers. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1221-web.png"},"website":"https://webtide.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1228,"name":"OFFIS e.V","member_since":"2016-11-11","renewal_date":"2026-11-01","description":{"long":"Knowlegdge Transfer

      A fast knowledge transfer from research into the economy is the crucial foundation for the economic, as well as the social well-being of a country. We have made this transfer our task: As an associated institute of the Carl von Ossietzky University in Oldenburg, OFFIS has, since its formation in 1991, converted scientific know-how from computer science into prototypes which are then developed further into marketable products by commercial partners. Hereby, OFFIS provides research and prototype developments for companies and institutions and this at the highest international level."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1228-web.png"},"website":"https://www.offis.de/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1235,"name":"Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR)","member_since":"2017-01-02","renewal_date":"2027-01-01","description":{"long":"

      \\r\\nDLR is the national aeronautics and space research centre of the Federal Republic of Germany. Its extensive research and development work in aeronautics, space, energy, transport and security is integrated into national and international cooperative ventures. In addition to its own research, as Germanys space agency, DLR has been given responsibility by the federal government for the planning and implementation of the German space programme. DLR is also the umbrella organisation for the nations largest project management agency.\\r\\n

      \\r\\n

      \\r\\nDLR has approximately 8000 employees at 20 locations in Germany: Cologne (headquarters), Augsburg, Berlin, Bonn, Braunschweig, Bremen, Bremerhaven, Dresden, Goettingen, Hamburg, Jena, Juelich, Lampoldshausen, Neustrelitz, Oberpfaffenhofen, Oldenburg, Stade, Stuttgart, Trauen, and Weilheim. DLR also has offices in Brussels, Paris, Tokyo and Washington D.C.\\r\\n

      \\r\\n

      \\r\\nDLRs mission comprises the exploration of Earth and the Solar System and research for protecting the environment. This includes the development of environment-friendly technologies for energy supply and future mobility, as well as for communications and security. DLRs research portfolio ranges from fundamental research to the development of products for tomorrow. In this way, DLR contributes the scientific and technical expertise that it has acquired to the enhancement of Germany as a location for industry and technology. DLR operates major research facilities for its own projects and as a service for clients and partners. It also fosters the development of the next generation of researchers, provides expert advisory services to government and is a driving force in the regions where its facilities are located.\\r\\n

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1235-web.png"},"website":"https://www.dlr.de/DE/Home/home_node.html","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1238,"name":"Payara Services Limited","member_since":"2017-01-31","renewal_date":"2027-02-01","description":{"long":"Payara Server - Robust, Reliable, Supported\\r\\n

      \\r\\nPayara Server is a fully supported, developer-friendly, open source application server. Payara Servers architecture is innovative, cloud-native and optimized for production deployments.\\r\\n

      \\r\\nMonthly releases, bug fixes and a 10-year support lifecycle optimizes Payara Server for production deployments. Payara Server is aggressively compatible with common ecosystem components and ensures future compliance with Jakarta EE. \\r\\n

      \\r\\nThe application server, compatible with Eclipse MicroProfile, is built and supported by a team of DevOps engineers dedicated to the continued development and maintenance of the open source software and committed to optimizing Payara Server as the best option for production Java EE applications.\\r\\n

      \\r\\n

      \\r\\nPayara Micro - Small, Simple, Serious\\r\\n

      \\r\\nPayara Micro is the open source, lightweight middleware platform of choice for containerized Java EE (Jakarta EE) microservices deployments. Less than 70MB in size, Payara Micro requires no installation or configuration and no need for code rewrites so you can build and deploy a fully working app within minutes.\\r\\n

      \\r\\nCompatible with Eclipse MicroProfile, Payara Micro is the microservices-ready version of Payara Server. You can run war files from the command line without any application server installation. Automatic and elastic clustering makes Payara Micro ideal for running Java EE applications in a modern virtualized infrastructure.\\r\\n

      \\r\\nPayara Micro also comes with a Java API so it can be embedded and launched from your own Java applications.\\r\\n

      \\r\\n

      \\r\\nPayara Enterprise - Software. Security. Stability. Support.\\r\\n

      \\r\\nPayara Enterprise lets you decide when to migrate from one release to the next with a 10-year support lifecycle and access to extra release streams. Youll maintain the security and stability of your applications environment from the JVM on up.\\r\\n

      \\r\\nOur global engineers go beyond the support help desk, offering fast issue resolution and 24-hour support options for your production Payara Server environment, while also giving customers priority on bug fixes and new features requests.\\r\\n

      \\r\\nPayara Enterprise customers enjoy a choice of 105 or 247 support, unlimited tickets, access to a private customer knowledge base and use of fully-supported builds of OpenJDK through our partnership with Azul."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1238-web.png"},"website":"https://www.payara.fish/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1239,"name":"SSI Schaefer IT Solutions GmbH","member_since":"2017-02-09","renewal_date":"2027-02-01","description":{"long":"

      The SSI Schaefer Group is the worlds leading provider of modular warehousing and logistics solutions. It employs approximately 10,500 people at its group headquarters in Neunkirchen (Germany), at more than ten domestic and international production sites, and at approximately 70 worldwide operative subsidiaries. Across six continents, SSI Schaefer develops and implements innovative industry-specific answers to its customers unique challenges. As a result, it plays a key role in shaping the future of intralogistics.

      \\r\\n\\r\\n

      SSI Schaefer designs, develops and manufactures systems for warehouses, industrial plants, workshops and offices. Its portfolio includes manual and automated solutions for warehousing, conveying, picking and sorting, plus technologies for waste management and recycling. In addition, SSI Schaefer is now a leading provider of modular, regularly updated software for in-house material flows. Its IT team, with a headcount in excess of 1,100, develops high-performance applications, and provides customers with in-depth advice on the intelligent combination of software with intralogistics equipment. SSI Schaefers broad IT offering, including its own WAMAS and SAP products, delivers seamless support for all warehouse and material flow management processes. Solutions from SSI Schaefer improve the productivity and efficiency of customer organizations not least through the highly precise monitoring, visualization and analysis of operational metrics for proactive intralogistics management.

      \\r\\n\\r\\n

      SSI Schaefer offers highly sophisticated, turnkey systems. As an international player, it can deliver one-stop solutions to all four corners of the earth. Its comprehensive portfolio encompasses design, planning, consulting, and customer-specific aftersales services and maintenance.

      \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1239-web.png"},"website":"https://www.ssi-schaefer.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Strategic Member","level":"WGSD","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1244,"name":"Associacao de Usuarios da Tecnologia Java, SouJava","member_since":"2017-03-14","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1244-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1246,"name":"PTA GmbH","member_since":"2017-04-10","renewal_date":"2027-04-01","description":{"long":"The range of services of the PTA GmbH meets the requirements of digitalization for companies in various industries (ranging from process management, ERP, CRM and industry systems to the development of individual software and hosting solutions \\\"Made in Germany\\\" as well as IT security). Since 1969, the PTA Group has been working with more than 400 employees for long-term customer and employee relationships and is distinguished by its independence from capital markets and manufacturers as a family-run company."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1246-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1248,"name":"Tomitribe Corporation","member_since":"2017-05-01","renewal_date":"2027-05-01","description":{"long":"It\\'s Tomitribe\\'s mission to provide support for consumers, educate people on TomEE, Open Source and Java EE and contribute to the success of everyone in the community. We believe Open Source is an ecosystem and everyone in that ecosystem has a role to play, from the people who produce it to the companies who use it.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1248-web.png"},"website":"https://tomitribe.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Strategic Member","level":"WGSD","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1251,"name":"M3S Research Unit at the University of Oulu","member_since":"2017-06-06","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1251-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1269,"name":"Calypso Networks Association","member_since":"2017-12-20","renewal_date":"2027-01-01","description":{"long":"Calypso technology has been designed to ensure interoperability between transportation networks equipments and is open to all manufacturers providers. It has been deployed for 20 years in 25 countries without any hacking reported since now and work with any kind of NFC portable objects: Smart Cards, Secures elements, Sim cards or HCE in Smart Phones.\\r\\n\\r\\nCNA is established in Brussels and has been founded in 2003, with the founder members of the european Calypso project : \\r\\nOTLIS, Ticketing operator of Lisbon\\r\\nACTV, Transport operator of Venice\\r\\nSTIB, Transport operator of Brussels\\r\\nLKRKN, Landrat of Constance\\r\\nRATP, Transport operator of Paris area\\r\\nSNCF, French national trainrail\\r\\n\\r\\nCNA is open to all actors playing a role in the Calypso environment, whether they are user of Calypso or a provider of Calypso. CNA has 80 active members and its main objectives are to define and direct the reference specifications, to implement a certification policy, to guarantee the compatibility of all current and future product, to establish a Calypso label issued by an independent organization, to promote Calypso to operators and manufacturers to yield its distribution, to contribute to the international standardization process, to facilitate and harmonize the shared members\\' needs and expriences. \\r\\n\\r\\nCNA is currently working on developping a full open source SDK for generic contactless Ticketing, which provides a library functions to developers, manages security and masks the complexity of a Calypso transaction.\\r\\n\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1269-web.png"},"website":"https://www.calypsonet-asso.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1286,"name":"Kynetics","member_since":"2018-03-21","renewal_date":"2027-04-01","description":{"long":"Kynetics offers a suite of Android and Linux operating systems (OS) for embedded systems, featuring popular application processors from NXP, Qualcomm, Mediatek and NVIDIA.\nKynetics empowers embedded system providers and manufacturers by offering a also comprehensive suite of products on top of its engineering services.\nDevelopment Tools for extending and simplifying the development and deployment process, allowing engineers to focus on core functionalities of their embedded applications.\nUpdate Factory enables secure and efficient remote updates and management of remote devices. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1286-web.png"},"website":"https://www.kynetics.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Innovator Member","level":"WGPAA","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1308,"name":"The Cloud Native Computing Foundation","member_since":"2018-04-26","renewal_date":"2027-05-01","description":{"long":"Cloud native technologies empower organizations to build and run\\r\\nscalable applications in modern, dynamic environments such as public,\\r\\nprivate, and hybrid clouds. Containers, service meshes, microservices,\\r\\nimmutable infrastructure, and declarative APIs exemplify this\\r\\napproach.\\r\\n\\r\\nThese techniques enable loosely coupled systems that are resilient,\\r\\nmanageable, and observable. Combined with robust automation, they\\r\\nallow engineers to make high-impact changes frequently and predictably\\r\\nwith minimal toil.\\r\\n\\r\\nThe Cloud Native Computing Foundation seeks to drive adoption of this\\r\\nparadigm by fostering and sustaining an ecosystem of open source,\\r\\nvendor-neutral projects. We democratize state-of-the-art patterns to\\r\\nmake these innovations accessible for everyone."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1308-web.png"},"website":"https://www.cncf.io/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1309,"name":"London Jamocha Community","member_since":"2017-01-09","renewal_date":"2027-05-01","description":{"long":"The LJC is a broad community of technologists and other associate with Java and JVM related technologies. Although it is based in London, UK - it has strong international membership due to its global programmes (such as Adopt a JSR and Adopt OpenJDK).\\r\\n\\r\\nThe LJC hosts regular events including:\\r\\n\\r\\n
        \\r\\n
      • Casual catch-ups in a cafe
      • \\r\\n
      • Hack days, evening talks
      • \\r\\n
      • un-conferences
      • \\r\\n
      • workshops
      • \\r\\n
      • mentoring
      • \\r\\n
      • demo days
      • \\r\\n
      • career mentoring by Londons Java specialists
      • \\r\\n
      • and much more!
      • \\r\\n
      \\r\\n\\r\\nThe LJC acts as a voice for Java engineers in London UK as well as globally. This includes but is not limited to helping run a build farm for Java, representing Java developers worldwide on the JCP (aka the Java standards body) as well as the Jakarta EE and MicroProfile communities."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1309-web.png"},"website":"https://www.meetup.com/Londonjavacommunity/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1310,"name":"Cirrus Link Solutions , LLC","member_since":"2018-05-01","renewal_date":"2027-05-01","description":{"long":"Cirrus Link Solutions provide secure and reliable IIOT software solutions enabled with MQTT that integrates process information throughout the organization bridging the IT / OT gap while supplying a superior OT solution. \\r\\n

      \\r\\nWith over 30 years of SCADA and Telemetry experience and the co-inventor of MQTT where M2M and IoT started, Cirrus Links understands the technology requirements to help companies achieve their business objectives. Our experiences and ingenuity has been integral in developing the technology to enable and effectively manage data assets for real-time controls to big data analytics for AI and predictive maintenance. We pride ourselves with our software delivering real solutions for IIOT and SCADA that are tried, tested and ready for production today.\\r\\n

      \\r\\nCirrus Link puts your business data to work faster and smarter. Break out of the information silo created by traditional software and use machines to share in real time with anyone in your company. With Cirrus Link machine to machine (M2M) technology, your people get on-time, real-time access to critical information. Allowing your business can make more informed, smarter decisions.\\r\\n

      \\r\\nLearn more at www.cirrus-link.com"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1310-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1312,"name":"Istanbul JUG","member_since":"2018-05-02","renewal_date":"2027-05-01","description":{"long":"The JUG IST acts as a voice for software engineers in Turkey as well as globally. The JUG Istanbul is a non-profit, big community of technologists associated with Java and JVM related technologies based in Istanbul, Turkey. List of our activities;\\r\\n\\r\\n

      \\r\\n
        \\r\\n
      • JavaDay Istanbul
      • \\r\\n
      • meetups, evening talks
      • \\r\\n
      • un-conferences
      • \\r\\n
      • workshops
      • \\r\\n
      • mentoring
      • \\r\\n
      • coding sessions
      • \\r\\n
      \\r\\n

      \\r\\nand much more!\\r\\n\\r\\nTwitter: @jug_istanbul\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1312-web.png"},"website":"https://www.jugistanbul.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1317,"name":"Inductive Automation","member_since":"2018-06-08","renewal_date":"2026-06-01","description":{"long":"Inductive Automation creates industrial software that empowers organizations to swiftly turn great ideas into reality by removing all technological and economic obstacles. \\r\\n\\r\\nBy cross-pollinating IT with SCADA technologies, Inductive Automation created Ignition software, the first universal industrial application platform with unlimited potential. Ignition empowers industrial organizations around the world and in virtually every industry, with an outstanding software platform and top-notch support."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1317-web.png"},"website":"https://inductiveautomation.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1319,"name":"Karakun AG","member_since":"2018-07-04","renewal_date":"2026-07-01","description":{"long":"Karakun is a growing team of very experienced software engineers developing agilely custom solutions for enterprises offering an optimal user experience. This includes portals (B2E, B2B, B2C), dashboards, and specialized solutions for numerous industries.\\r\\n\\r\\nOur offering includes full-stack development of custom software solutions especially for the cloud. Consequently, we are also engaging with activities around Jakarta EE.\\r\\n\\r\\nWe especially deliver platforms and applications for the integrated management of measurement data to our customers. Therefore, we are contributing to the openMDM working group (https://www.openmdm.org/) and its associated projects.\\r\\n\\r\\nAnd, finally, Karakun offers technology and solutions for semantic enterprise search with high security requirements."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1319-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1320,"name":"Liferay International Limited","member_since":"2025-05-06","renewal_date":"2027-05-01","description":{"long":"Liferay makes software that helps companies create digital experiences on web, mobile and connected devices. Our platform is open source, which makes it more reliable, innovative and secure. We try to leave a positive mark on the world through business and technology. Hundreds of organizations in financial services, healthcare, government, insurance, retail, manufacturing and multiple other industries use Liferay."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1320-web.png"},"website":"https://www.liferay.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1321,"name":"iJUG Interessenverbund der Java-User Groups e V","member_since":"2018-07-10","renewal_date":"2026-07-01","description":{"long":"The interest group of Java User Groups iJUG e.V. is a coalition of approximately 40 Java User Groups from Germany, Switzerland and Austria. The organization promotes the common interests of its members to developers, manufacturers, distributors and the general public."},"logos":{"print":"https://membership.eclipse.org/organization/images/1321-print.eps","web":"https://membership.eclipse.org/organization/images/1321-web.png"},"website":"https://www.ijug.eu/en/home/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Participant Member","level":"WGAPS","working_group":"adoptium"},{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1329,"name":"Advantest Europe GmbH","member_since":"2018-08-10","renewal_date":"2026-08-01","description":{"long":"A world-class technology company, Advantest is the leading producer of automatic test equipment (ATE) for the semiconductor industry and a premier manufacturer of measuring instruments used in the design and production of electronic instruments and systems. Its leading-edge systems and products are integrated into the most advanced semiconductor production lines in the world. The company also focuses on R&D for emerging markets that benefit from advancements in nanotech and terahertz technologies, and has introduced multi-vision metrology scanning electron microscopes essential to photomask manufacturing, as well as groundbreaking 3D imaging and analysis tools. Founded in Tokyo in 1954, Advantest established its first subsidiary in 1982, in the USA, and now has subsidiaries worldwide. More information is available at www.advantest.com."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1329-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1330,"name":"kuehn & weyh Software GmbH","member_since":"2018-09-01","renewal_date":"2026-09-01","description":{"long":"kwsoft is a medium-sized software manufacturer and solution provider, with corporate headquarters in Freiburg, Germany.\\r\\n

      \\r\\nThe CCM solution Serie M/ enables high-quality customer communication that is precisely tailored to the recipient in terms of content, form and medium. The solution gives administrators the greatest possible control over their document processes because it offers a standardized solution from a single vendor - from document composition and creation to multichannel output management."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1330-web.png"},"website":"https://kwsoft.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1339,"name":"OpenDevise Inc","member_since":"2018-12-29","renewal_date":"2027-01-01","description":{"long":"

      OpenDevise helps organizations achieve faster growth through better documentation.

      \\r\\n

      OpenDevise: Tools. Workflows. Information Architecture.

      \\r\\n

      We develop automated tools and build processes that take the complexity, human effort, and anxiety out of deploying documentation sites. OpenDevise is the creator of Antora, a documentation site generator that enables technical writers to create, manage, remix, and publish documentation sites from AsciiDoc-based content sourced from a selection of versioned content repositories.

      \\r\\n

      DevOps for Documentation Teams

      \\r\\n

      We upgrade documentation teams to a modern, agile workflow for creating, reviewing, testing, and publishing documentation composed in the lightweight markup language AsciiDoc. As the maintainers of the leading AsciiDoc processor, Asciidoctor, we have a deep understanding of how to best integrate and adapt AsciiDoc into your documentation teams workflow. OpenDevise helps teams save time, minimize risk, and increase their writing and publishing productivity. A few of the ways we assist are through toolchain configuration, publishing pipeline architecture, UI design, and extension development.

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1339-web.png"},"website":"https://opendevise.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"df911e0adcad1a1c51df","description":"","level":"WGPL","working_group":"asciidoc"}],"is_active_member":true},{"organization_id":1345,"name":"Linux Foundation","member_since":"2019-04-02","renewal_date":"2027-04-01","description":{"long":"Founded in 2000, the Linux Foundation is supported by more than 1,000 members and is the worlds leading home for collaboration on open source software, open standards, open data, and open hardware. Linux Foundations projects are critical to the worlds infrastructure including Linux, Kubernetes, Node.js, and more. The Linux Foundations methodology focuses on leveraging best practices and addressing the needs of contributors, users and solution providers to create sustainable models for open collaboration. For more information please visit us at www.linuxfoundation.org."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1345-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1349,"name":"Eteration A.S","member_since":"2019-05-31","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1349-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1352,"name":"AVL List GmbH","member_since":"2019-06-17","renewal_date":"2026-07-01","description":{"long":"AVL is the world\\'s largest independent company for the development, simulation and testing of powertrain systems (hybrid, combustion engine, transmission, electric drive, batteries, fuel cell and control technology) for passenger cars, commercial vehicles, construction, large engines and their integration into the vehicle. The company has decades of experience in the development and optimization of powertrain systems for all industries. As a global technology leader, AVL provides complete and integrated development environments, measurement and test systems as well as state-of-the-art simulation methods. As a pioneer in the field of innovative solutions, such as diverse electrification strategies for powertrains, AVL is increasingly taking on new tasks in the field of autonomous driving, especially on the basis of subjective human sensations (driveability, connectivity, ADAS, etc.). In the competition of technologies internal combustion engine, battery/electric drive and fuel cell and their combinations, AVL is working intensively and with the same priorities. AVL has digitized the vehicle development process with state-of-the art and highly scalable IT, software and technology platforms, and creates new customer solutions in the areas of big data, artificial intelligence, simulation and embedded systems in an agile and integrated development environment."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1352-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1367,"name":"Information Systems & Databases (DBIS,Informatik 5) of RWTH Aachen University","member_since":"2024-03-12","renewal_date":"2027-03-01","description":{"long":"Across the world and for many decades, the Laboratory for Machine Tools and Production Engineering (WZL) of RWTH Aachen University has stood for successful and forward-thinking research and innovation in the area of production engineering.\\r\\n\\r\\nUnder the leadership of four professors, Thomas Bergs, Christian Brecher, Robert Schmitt and Guenther Schuh, the WZL is conducting research in six areas - production technology, machine tools, production systems, transmission technology, production metrology and quality management - on the future-oriented design of production in high-wage countries. \\r\\n\\r\\nTogether with industry partners from various sectors, the WZL develops solutions for a wide variety of production scenarios in both publicly funded and bilateral projects. \\r\\n\\r\\nThese activities are being consolidated on the RWTH Aachen Campus in the Cluster Production Engineering."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1367-web.png"},"website":"https://www.wzl.rwth-aachen.de/go/id/sijq/?lidx=1","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1374,"name":"Lulea University of Technology","member_since":"2019-09-25","renewal_date":"2026-10-01","description":{"long":"Lule University of Technology is experiencing strong growth with world-leading competence in several areas of research. Our research is conducted in close collaboration with industries such as Bosch, Ericsson, Scania, LKAB, SKF and leading international universities. Lule University of Technology has a total turnover of 190M per year. We currently have 1800 employees and 16 500 students.\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1374-web.png"},"website":"https://www.ltu.se/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1376,"name":"Cedalo GmbH","member_since":"2019-10-07","renewal_date":"2026-10-01","description":{"long":"Streamsheets are a powerful no-code platform to build applications for industrial automation, connectivity and event stream processing.\\r\\n\\r\\nThanks to the familiar spreadsheet user interface also non-programmers create full-fledged applications and services to process data from machines, sensors, apps, APIs and more. With Streamsheets users build customized digital solutions on the edge, on-premises and in the cloud. \\r\\n\\r\\nThe Mosquitto Project is one of the most popular Message Brokers and highly suitable for a broad range of application areas in the Internet of Things and beyond."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1376-web.png"},"website":"https://cedalo.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1380,"name":"Huawei Technologies Co., LTD.","member_since":"2015-06-23","renewal_date":"2026-10-01","description":{"long":"Huawei is a leading global information and communications technology (ICT) solutions provider. Driven by a commitment to sound operations, ongoing innovation, and open collaboration, we have established a competitive ICT portfolio of end-to-end solutions in telecom and enterprise networks, devices, and cloud technology and services. Our ICT solutions, products, and services are used in more than 170 countries and regions, serving over one-third of the world\\'s population. With more than 180,000 employees, Huawei is committed to enabling the future information society, and building a Better Connected World."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1380-web.png"},"website":null,"levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"},{"document_id":"efcdef5b284754c43de2","description":"Strategic Member","level":"WGSD","working_group":"orc"},{"document_id":"f348c2873ca8ed8e9eca","description":"Strategic Member","level":"WGSD","working_group":"oniro"}],"is_active_member":true},{"organization_id":1382,"name":"Software Institute, Università della Svizzera italiana","member_since":"2019-11-26","renewal_date":"2026-12-01","description":{"long":"At the Software Institute, we discover, design, and develop new ideas that ease the conception of modern software systems. Our research is rooted both in sound theoretical models as well as practical, real-life questions that impact modern society."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1382-web.png"},"website":"https://si.usi.ch","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1383,"name":"Bird Software Solutions Ltd","member_since":"2019-11-27","renewal_date":"2026-12-01","description":{"long":"BIRD Software Solutions Ltd provides solutions and consultancy to support the use of the Banks Integrated Reporting Directory (BIRD) project which is managed by the European Central Bank. (https://www.ecb.europa.eu/stats/ecb_statistics/co-operation_and_standards/reporting/html/bird_dedicated.en.html ) "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1383-web.png"},"website":"https://www.birdsoftwaresolutions.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1384,"name":"CANARY LABS INC.","member_since":"2019-12-03","renewal_date":"2026-12-01","description":{"long":"Considering most operations have thousands (if not hundreds of thousands) of data points, how you collect and store your data is vitally important to your success.\\r\\n\\r\\nAt Canary, we believe making your data easy to store and recall makes you more successful. We\\'ve spent over 20 years building a time series database that sets the standard in any industry.\\r\\n\\r\\nThe Canary System allows you to:
      \\r\\n\\r\\nCollect and store billions of data values.
      \\r\\nSpend less time on database management.
      \\r\\nNever worry about performance or losing your data.
      \\r\\n\\r\\nPaired with the MQTT Sparkplug B protocol, you can easily scale your organization from just few tags to millions without spending months of man hours."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1384-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1387,"name":"DENSO AUTOMOTIVE Deutschland GmbH","member_since":"2019-12-16","renewal_date":"2027-01-01","description":{"long":"DENSO AUTOMOTIVE Deutschland GmbH is a subsidiary of DENSO Corporation which is a global automotive supplier company."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1387-web.png"},"website":"https://www.denso.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1390,"name":"OSB Alliance- Bundesverband für digitale Souveränität e.V.","member_since":"2020-01-01","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1391,"name":"TmaxSoft Co., Ltd","member_since":"2020-02-01","renewal_date":"2027-02-01","description":{"long":"TmaxSoft was founded on the principle that there is always a better way. Nothing will stop us from creating better solutions that improve your business in ways that other companies cant. Or wont. A global software innovator focused on cloud, infrastructure and legacy modernization, we give you the freedom to take control of your technology. Our complete stack of software solutions help you efficiently manage and fully leverage your critical data. This provides global IT customers with software-defined mainframe rehosting, middleware and RDBMS technology that enables IT to actively and effectively contribute to achieving business objectives. With our remarkable technology, fresh perspective, collaborative spirit, and unusual clarity and transparency, youll finally have the choice you deserve. Along with freedom from status quo technology, more opportunities and faster ways to innovate, reduced risk of change, greater cost savings, and a better customer experience. \\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1391-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1397,"name":"Kingdee Apusic Cloud Computing Co.,Ltd","member_since":"2020-02-15","renewal_date":"2027-02-01","description":{"long":"Kingdee Apusic cloud computing Co., Ltd. was founded in 2000, formerly known as Kingdee middleware Co., Ltd., which is a subsidiary of Kingdee group and a member of China Electronics Technology Group Taiji Co., Ltd. It is a key software enterprise in the national planning and layout and a leading cloud service provider of digital government, basic software service provider, and public financial management software service provider of China."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1397-web.png"},"website":"https://www.apusic.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1399,"name":"NEC Corporation","member_since":"2021-10-14","renewal_date":"2026-08-01","description":{"long":"NEC provides products for business, ranging from terminals to network and computer equipment, software products and service platforms, as well as integrated platforms based on them. We deliver labor-saving and efficient platforms for customers, while at the same time creating new value such as IoT platforms based on ICT as we contribute to the expansion of solutions for society."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1399-web.png"},"website":"https://www.nec.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1401,"name":"Primeton Information Technologies, Inc","member_since":"2020-02-18","renewal_date":"2027-03-01","description":{"long":"Primeton was established on March 36, 2003 and changed from a limited liability company to a joint stock company in 2010. The company has obtained a number of national honor certifications, such as National Enterprise Technology Center, Postdoctoral Research Station, and continuously passed the International Software Capability Maturity Model Integration (CMMI) Level 5 Certification and ISO9001 Quality Management System Certification. It has mastered 41 key and major core technologies and a number of reserve technologies in the field of software foundation platforms, 27 invention patents and172 software copyrights. The company participated in two important SOA international technical specifications of SCA / SDO and 11 national technical standards Formulation.\\r\\nPrimeton is a professional software foundation platform provider. It provides independent, controllable, safe and reliable software foundation platforms and application software development services for large and medium-sized users in the financial, government, energy, telecommunications, manufacturing and other industries.\\r\\nSince its establishment, the company has continued to cultivate the field of software foundation platforms. After more than ten years of technology and experience, it has established a \\\"standard product + platform customization + application development\\\" business model, which includes the sales and maintaining service of standard software products of the software foundation platform, platform customization and application development services.\\r\\nPrimeton has been committed to the construction of independent research and development and innovation capabilities of the core technology of the software foundation platform. It has created a component-based technology platform and core technology combination, and formed a systematic technology research and development capability, the platformized capability of product development and comprehensive project implementation methodology. Based on core technologies and innovation capabilities, Primeton provides customers with software products and technical services, helping customers flexibly and quickly respond to complex and changing business scenarios and successfully achieve business transformation under new generation information technologies such as cloud computing and big data.\\r\\nAfter more than ten years of focused development, Primeton enjoys high brand awareness in the field of software foundation platforms. In 2018, there were 120 Chinese companies in the Fortune Global 500, 44 of which chose Primeton Informations software platform products or technical solutions. The technical performance, maturity and safety and reliability of the company\\'s products and technical solutions have been verified in thousands of large-scale and key projects in national economic key areas such as finance, government affairs, energy, telecommunications, and manufacturing. Primeton has a China Registration and Clearing Corporation , Shanghai Gold Exchange, China Mobile, General Administration of Customs and other large and medium-sized customers in the industry are all Primetons regular customers. Primeton has gradually changed the absolute dominant position of international brands in the domestic software infrastructure platform market."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1401-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Enterprise Member","level":"WGDSA","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1405,"name":"Barcelona Supercomputing Center (BSC)","member_since":"2020-03-05","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1405-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1409,"name":"Futurewei Technologies, Inc.","member_since":"2020-03-06","renewal_date":"2026-10-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1409-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f348c2873ca8ed8e9eca","description":"Silver Member","level":"WGHLP","working_group":"oniro"}],"is_active_member":true},{"organization_id":1423,"name":"University of Bologna","member_since":"2021-10-14","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1423-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1427,"name":"openKONSEQUENZ eG","member_since":"2020-03-09","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1427-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1428,"name":"Alibaba Cloud","member_since":"2020-05-01","renewal_date":"2027-05-01","description":{"long":"As a business unit of Alibaba Group (NYSE: BABA), Alibaba Cloud provides a comprehensive suite of global cloud computing services to power both our international customers online businesses and Alibaba Groups own e-commerce ecosystem. In January 2017, Alibaba Cloud became the official Cloud Services Partner of the International Olympic Committee.\\r\\nBy harnessing, and improving on, the latest cloud technology and security systems, we tirelessly work towards our vision - to make it easier for you to do business anywhere, with anyone in the world."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1428-web.png"},"website":"https://www.alibabacloud.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"},{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1434,"name":"Polytechnique Montreal","member_since":"2020-03-27","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1434-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1436,"name":"ETH Zurich","member_since":"2020-04-02","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1436-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1437,"name":"Broadcom","member_since":"2008-02-28","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1437-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"","level":"WGSM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1441,"name":"Topio Networks","member_since":"2020-04-28","renewal_date":"2027-05-01","description":{"long":"Topio Networks, an industry research platform, \\r\\naccelerates markets and businesses by providing \\r\\ndetailed information about use cases, verticals \\r\\nand industries. \\r\\n\\r\\nTopio Networks offers detailed data insights and natural language analysis about the shape, structure and sizing of the thousands of use cases, verticals and \\r\\ntechnologies that are the building blocks of the fourth \\r\\nindustrial revolution. Our data is constantly fed by \\r\\nthe daily insights generated by our taxonomy driven, \\r\\nhuman curated AI Platform. \\r\\n\\r\\nThe Topio Networks Market Intelligence Center provides free access to our industry research with detailed data about market sizing, innovations, funding and marketing activities for each specific use cases, industries and emerging technologies. \\r\\n\\r\\nIn addition, Topio Networks offers acceleration \\r\\nservices to businesses by providing the content \\r\\nnecessary to develop their go to market strategies, by \\r\\ntracking the company content and mapping it to the \\r\\nbest practices of the industry and providing market \\r\\naccess through events and lead generation.\\r\\nTo learn more about how Topio Networks applies \\r\\nAI and Natural Language Processing to create \\r\\ncomprehensive research about thousands of use \\r\\ncases,"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1441-web.png"},"website":"https://www.topionetworks.com","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1442,"name":"Chevron Technical Center","member_since":"2020-04-29","renewal_date":"2027-05-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1442-web.png"},"website":"https://www.chevron.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1443,"name":"Open Source Robotics Foundation","member_since":"2020-05-06","renewal_date":"2027-05-01","description":{"long":"We offer robotics R&D, consulting, custom engineering, and application development services to industry and government. We work with companies large and small and public agencies around the world. Whether you want to learn more about Gazebo, need to streamline your ROS-based product development, or are looking for a partner for your next R&D program, we\\'re here to help. The unifying theme of our team and our work is openness. We use and we build open systems. To the greatest extent possible, we freely distribute our work product, whether software, hardware, or documentation, under an open source license."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1443-web.png"},"website":"https://www.openrobotics.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1451,"name":"Institut für angewandte Systemtechnik Bremen Gmbh","member_since":"2020-06-18","renewal_date":"2026-06-01","description":{"long":"What is ATB?
      \\r\\nATB is an application oriented research institute founded jointly by the Free Hanseatic City of Bremen and several leading industrial enterprises in Bremen area in 1991.\\r\\n

      \\r\\nATB is a part of the long-term strategy of the Free Hanseatic City of Bremen to sustain economy in northern Germany and, particularly, in Bremen by strengthening innovation potentials of industrial enterprises and other organisations.\\r\\n

      \\r\\nATB is a highly innovative and efficient technology centre providing system technology related services to a wide spectrum of enterprises and organisations, thereby increasing their ability to remain competitive. ATB has developed into a dynamically expanding research institute operating successfully on the national, European and world-wide market and offering to partners a high level of expertise in several technological domains.\\r\\n

      \\r\\nWhat does ATB offer?
      \\r\\nATB offers\\r\\n

        \\r\\n
      • services in process/product innovation activities based on advanced Information and Communication Technology solutions
      • \\r\\n
      • flexibility of a dynamic, performance and application oriented research institute
      • \\r\\n
      • remarkable competencies in both
      • \\r\\n
          \\r\\n
        • technical and research domains
        • \\r\\n
        • management of complex technical projects
        • \\r\\n
        \\r\\n
      • High expertise in several domains based on effective team-building of staff members with long-term experience and agile young researchers
      • \\r\\n
      \\r\\nThe basis for all projects is a cooperative partnership with clients, allowing for a collaborative and effective approach to achieve the clients innovation targets.\\r\\n
      \\r\\nATB provides its services within:\\r\\n
        \\r\\n
      • Application oriented research projects supported by regional, national, European and other international funding schemes
      • \\r\\n
      • Direct research projects with clients
      • \\r\\n
      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1451-web.png"},"website":"https://www.atb-bremen.de","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1453,"name":"University of Oslo, Dept of Informatics","member_since":"2020-07-07","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1458,"name":"Beijing Tongtech Co., Ltd","member_since":"2020-07-21","renewal_date":"2026-08-01","description":{"long":"Beijing Tongtech Co., Ltd (Tongtech) is an industry leading infrastructure software and IT solutions provider. With its state of the art technology and products, Tongtech provides its customers with a complete family of application infrastructure products ranging from middleware, information security solutions to intelligent transportation system (ITS) solutions. Over the years, Tongtechs products and solutions has helped its customers leverage the power of internet to upgrade their businesses in a safe and effective manner.\\r\\n\\r\\nTongtech has been named as one of the \\\"National Key Software Enterprises\\\" for 12 consecutive years, and was granted AAA credit ratings by the Ministry of Commerce as well as the State-owned Asset Supervision and Administration Commission of the State Council (SASAC). In the field of technology, Tongtech is the core member of the Java Community Process Program (JCP) and the National Information Technology Standardization Committee, and has participated in developing industry standards for JavaEE, SOA/middleware, IEC smart city and other international and domestic standards organizations. Our company is also a research center for Major National Science and Technology Programs and has won the \\\"National Science and Technology Progress Award\\\" granted by the State Council for our achievements and efforts.\\r\\n\\r\\nAs a pioneer in the middleware software industry, our software products and solutions are widely used in all kinds of industries in China, with more than 2,000 enterprise users spreading across industries such as finance, communication, government, energy, and transportation. Tongtech also enjoyed good partnership with 500 partners."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1458-web.png"},"website":"https://www.tongtech.com/sy.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1465,"name":"RIOS Lab","member_since":"2020-09-18","renewal_date":"2026-10-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1465-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1469,"name":"Atlanta Java Users Group, Inc","member_since":"2020-10-05","renewal_date":"2026-10-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1469-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Corporate Member","level":"abcde","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1473,"name":"Circuitsutra Technologies Pvt Ltd","member_since":"2020-10-19","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1473-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1474,"name":"Apex.AI, Inc","member_since":"2020-10-19","renewal_date":"2026-11-01","description":{"long":"Apex.AI was founded in 2017 in Palo Alto to build robust, reliable, safe, secure, and certified software for autonomous mobility systems. \\r\\n
      \\r\\n\\r\\nCore products:\\r\\n
      \\r\\n1. Apex.Grace is a runtime software environment, which is built on ROS 2 (Robot Operating System) and provides a production-grade safety-certified realtime framework for developing safe and secure applications. \\r\\n
      \\r\\n2. Apex.Ida is a highly optimized communication middleware based on Eclipse iceoryx and Eclipse Cyclone DDS"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1474-web.png"},"website":"https://www.apex.ai/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1476,"name":"Data In Motion Consulting GmbH","member_since":"2020-11-10","renewal_date":"2026-11-01","description":{"long":"

      Founded in 2010, in Jena (Thuringia, Germany), Data In Motion Consulting GmbH provides a strong consolidated experience in the fields of Modeling, Software Engineering, Architecture and Consulting.

      \\r\\n

      We assist our customers in the development of their projects, guiding them trough the whole process, while providing them with the required strategies and tools to be able to \\\"walk on their own\\\" in the future.

      \\r\\n

      Our skill set goes from the more technical expertise in model-driven software development and architecture, data analysis and independent R&D, to more managerial experience in project and product management, and moderation of the whole business process.

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1476-web.png"},"website":"https://www.datainmotion.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1480,"name":"AICAS GmbH","member_since":"2020-11-30","renewal_date":"2027-01-01","description":{"long":"aicas embraces the mission to bring intelligence to devices and unlock realtime data. The international high-tech company creates embedded IoT and edge-to-cloud solutions.\n\nAcross the globe, aicas connects over 25 million devices and vehicles to the cloud, simplifying access and control of edge devices and their data. Large industrial companies and leading automotive manufacturers use aicas EdgeSuite and JamaicaVM to master their digital transformation and open up new business models.\n\nCreating, deploying and operating edge-to-cloud solutions: aicas makes it happen. \nFast. Simple. Reliable."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1480-web.png"},"website":"https://www.aicas.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"}],"is_active_member":true},{"organization_id":1481,"name":"Beijing Thunisoft Information Technology Co., Ltd","member_since":"2020-11-30","renewal_date":"2026-12-01","description":{"long":"Thunisoft adheres to the enterprise spirit of \\\"Self-discipline and Social Commitment\\\", adheres to the values of honesty and integrity, takes \\\"Continuous innovation,to serve for customers\\' success\\\" as its mission, focuses on software and information services, providing customers with a full range of solutions and services for their informatization business, and is your trusted expert in intelligent information services."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1481-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1482,"name":"Makewave AB","member_since":"2020-12-09","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1482-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"68db2919ffe553250ae8","description":"Strategic Member","level":"WGSD","working_group":"osgi"}],"is_active_member":true},{"organization_id":1485,"name":"Garden State Java User Group (GSJUG)","member_since":"2021-01-06","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1485-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Guest Member","level":"WGSAP","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1486,"name":"The Johns Hopkins University","member_since":"2021-01-11","renewal_date":"2026-11-01","description":{"long":"Founded in 1876 as the nation’s first research university, Johns Hopkins has been advancing knowledge and bringing discoveries to the world for nearly 150 years."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1486-web.png"},"website":"https://www.jhu.edu/about/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1487,"name":"Shandong Cvicse Middleware Co.,Ltd","member_since":"2021-01-11","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1487-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Enterprise Member","level":"WGDSA","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1488,"name":"SignalFire Telemetry ","member_since":"2021-01-18","renewal_date":"2027-01-01","description":{"long":"The SignalFire wireless platform is offered with 900Mhz or with LTE-M1 for flexibility and cost effectiveness. The architecture provides for long-range wireless networks designed for remote monitoring and control in challenging outdoor environments. The nodes are integrated with a variety of sensors to work with level, pressure, temperature and flow meters, as well as offering critical asset control of valves, pumps, fans, heaters and an array of other devices.\\r\\n\\r\\nThe SignalFire wireless system has been deployed in thousands of installations in oil & gas fields and pipelines, petrochemical processing plants, crop and irrigation monitoring systems, transportation monitoring systems, and municipal infrastructure monitoring and control systems, as well as a variety of other applications.\\r\\n\\r\\nOur nodes can provide both communications and power to your sensors, making your application truly wireless. A wide range of sensor types are compatible, including 4-20 mA, 1.5V, Modbus, Hart, Digital I/O and other analog and digital interfaces.\\r\\n\\r\\nTo find out more, contact SignalFire and tell us about your toughest monitoring and control challenge."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1488-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Participant Member","level":"WGAPS","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1489,"name":"Netherlands Organisation for applied scientific research TNO","member_since":"2021-01-21","renewal_date":"2027-02-01","description":{"long":"

      About TNO

      \\r\\n

      The Netherlands Organization for Applied Scientific Research (TNO) is an independent research organization. We connect people and knowledge to create innovations that boost the sustainable competitive strength of industry and well-being of society. Now and in the future. This is our mission and it is what drives us, the over 3.000 professionals at TNO, in our work every day. We work in collaboration with partners and focus on transitions or changes in nine social themes that we have identified together with our stakeholders.

      \\r\\n\\r\\n

      Information & Communication Technology: \\'Interpreting and accelerating digital transformation\\'

      \\r\\n

      TNOs Information & Communication Technology unit aims to assist its clients, partners and other TNO units through complex digital transformations by leveraging its know-how in ICT, policy and business models. In concrete terms, we work in three main areas: data-driven innovations, robust networks, and integrated computer systems. We operate in domains such as ICT, telecoms, defence & security, high-tech industry, the energy sector, mobility and logistics. \\r\\n

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1489-web.png"},"website":"https://www.tno.nl/en/focus-areas/information-communication-technology/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1491,"name":"CSEM SA","member_since":"2021-01-28","renewal_date":"2027-02-01","description":{"long":"We are a public-private, non-profit technology innovation center. Dedicated to transforming brilliant ideas into industrial reality. With the support of the Swiss Federal government our mission is to secure our nation’s status as a global tech and innovation leader."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1491-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1492,"name":"The University of Sheffield","member_since":"2021-02-02","renewal_date":"2027-02-01","description":{"long":"The University of Sheffield Advanced Manufacturing Research Centre (AMRC) is a network of world-leading research and innovation centres working with manufacturing companies of any size from around the globe.\\r\\n\\r\\nWe specialise in carrying out world-leading research into advanced machining, manufacturing and materials, which is of practical use to industry.\\r\\nWe transform industrial and economic performance by making step changes in productivity, increasing competitiveness, developing new products and processes and training new talent and skills.\\r\\n\\r\\nOur 125-plus industrial partners range from global giants like Boeing, Rolls-Royce, BAE Systems and Airbus to small companies. Businesses can work with us on a one-off project, or join us as a member for long-term collaboration.\\r\\nOur operations have grown significantly since we were founded in 2001 and in 2003 we became the anchor tenant on the Advanced Manufacturing Park at Catcliffe, South Yorkshire.\\r\\n\\r\\nThe AMRC now employs over 500 highly qualified researchers and engineers from around the globe, on the Advanced Manufacturing Park and Sheffield Business Park in South Yorkshire, as well as in Broughton and Preston."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1492-web.png"},"website":"https://www.amrc.co.uk","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Guest Member","level":"WGSAP","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1494,"name":"Adobe","member_since":"2021-02-05","renewal_date":"2027-02-01","description":{"long":"Adobe"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1494-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"68db2919ffe553250ae8","description":"Participant Member","level":"WGAPS","working_group":"osgi"}],"is_active_member":true},{"organization_id":1501,"name":"Opto 22","member_since":"2021-04-08","renewal_date":"2027-01-01","description":{"long":"For over 45 years, OEMs, machine builders, system integrators, and IT and operations personnel have looked to us for reliable products that deliver cutting-edge innovation at an affordable price.\\r\\n\\r\\nToday, we design and manufacture industrial control and IIoT products, like groov EPIC and groov RIO, that bridge the gap between IT and OT, following a core philosophy of open, standards-based technology.\\r\\n\\r\\nOpto 22 products are deployed worldwide in industrial automation, process control, building automation, industrial refrigeration, remote monitoring, and data acquisition applications through our global network of distributors and system integrators.\\r\\n\\r\\nOpto 22\\'s groov family of industrial edge controllers and I/O is designed from the ground up with integrated control, connectivity, and security tools to help you connect automation, enterprise, and cloud data.\\r\\n\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1501-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1503,"name":"Flow Software, Inc.","member_since":"2021-04-22","renewal_date":"2027-05-01","description":{"long":"The Flow Information Platform simplifies the creation and sharing of operational and strategic decision support information across your organization.\\r\\n\\r\\nCombine and transform data from multiple sources into a single namespace representing your \\\"single version of the truth\\\". Share this truth with people via configurable dashboards or with systems via configurable integrations.\\r\\n\\r\\nFlow is an \\\"ETL for OT\\\", a \\\"DataOps\\\" platform, that ingests and transforms complex data into KPIs, making it accessible when it is needed the most. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1503-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1504,"name":"Interuniversitair Micro-Electronica Centrum vzm (IMEC)","member_since":"2021-05-11","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1504-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"},{"document_id":"68db2919ffe553250ae8","description":"Guest Member","level":"WGSAP","working_group":"osgi"},{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1505,"name":"The Apache Software Foundation","member_since":"2021-05-11","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1505-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1506,"name":"Beijing Baolande Software Corporation","member_since":"2021-05-14","renewal_date":"2027-05-01","description":{"long":"Beijing Baolande Software Corporation founded in 2008, is a high-tech software enterprise focusing on basic software development and promotion."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1506-web.png"},"website":"https://www.bessystem.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1512,"name":"Fondazione LINKS","member_since":"2021-07-20","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1512-web.png"},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1513,"name":"Trialog ","member_since":"2021-08-10","renewal_date":"2026-08-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1513-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1515,"name":"NOI Techpark","member_since":"2021-08-26","renewal_date":"2026-09-01","description":{"long":"We are NOI. South Tyrol's innovation district.\nInnovation, research, development. 1.000+ entrepreneurs, researchers, start-ups and students are working at NOI for an ecological and economic conversion of society. At NOI, research is practice-oriented. The needs of companies give rise to scientific work. \nAt NOI, we focus on four technology fields: Green, Food, Digital, Automotive & Automation. We are rooted in South Tyrol and in South Tyrolean society. At the same time, we work with an international slant. \nFor R&D projects we offer services and knowhow through our dataspaces platform Open Data Hub https://opendatahub.com and the Free Software Lab https://freesoftwarelab.noi.bz.it "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1515-web.png"},"website":"https://noi.bz.it/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Supporter Member","level":"WGSM","working_group":"dataspace"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"f348c2873ca8ed8e9eca","description":"Silver Member","level":"WGHLP","working_group":"oniro"}],"is_active_member":true},{"organization_id":1519,"name":"European Space Agency","member_since":"2021-09-20","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1519-web.png"},"website":null,"levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[],"is_active_member":true},{"organization_id":1520,"name":"Volkswagen Aktiengesellschaft","member_since":"2021-10-04","renewal_date":"2026-06-01","description":{"long":"The Volkswagen Group comprises ten brands from five European countries: Volkswagen, Volkswagen Commercial Vehicles, ŠKODA, SEAT, CUPRA, Audi, Lamborghini, Bentley, Porsche and Ducati. On our way to becoming a sustainable mobility provider with a role model function in the areas of environment, safety and integrity, Volkswagen Group Innovation rely on a cross-brand and efficient research network. This network connects experts, enables partnership-based cooperation at eye level, creates an innovative working environment and bundles activities in order to increase synergies and efficiencies across the Volkswagen group"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1520-web.png"},"website":"https://www.volkswagen.de/de.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"aea0514f5cc2d0407ffd","description":"Driver Member","level":"WGPAE","working_group":"openpass"}],"is_active_member":true},{"organization_id":1521,"name":"Industrial Digital Twin Association","member_since":"2021-10-06","renewal_date":"2026-10-01","description":{"long":"The IDTA is the first point of contact for the standardised Digital Twin and offers all industrial organisations a platform for participation. The aim is to establish the Digital Twin for components, machines, plants and entire factories as an open source technology and to develop it further together with industry.\nThe core technology for the implementation is the Asset Administration Shell (AAS), that enables quick and easy access to data over the entire life cycle thanks to standardised software structure, interfaces and semantics using current security mechanisms. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1521-web.png"},"website":"https://industrialdigitaltwin.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1524,"name":"University of Saskatchewan","member_since":"2021-10-15","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1524-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1525,"name":"University of California, Santa Barbara","member_since":"2021-10-15","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1530,"name":"Institute of Software Chinese Academy of Sciences","member_since":"2021-10-15","renewal_date":"2026-08-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1530-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1532,"name":"Asiainfo Technologies limited","member_since":"2024-04-15","renewal_date":"2026-11-01","description":{"long":"Started in 1993, AsiaInfo Technologies Limited is a leading provider of information technology products and services and a pioneering provider of full-stack digital intelligence capabilities. AsiaInfo provides end-to-end and full-link digital intelligence services for hundreds of industries based on its full-stack digital intelligence capabilities such as consulting and planning, product R&D, product delivery, system integration, data operation, intelligent decision-making, customer services. \n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1532-web.png"},"website":"https://www.asiainfo.com/en_us/index.html","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1540,"name":"Amadeus S.A.S.","member_since":"2021-11-23","renewal_date":"2026-11-01","description":{"long":"Travel powers progress. Amadeus powers travel. Amadeus solutions connect travelers to the journeys they want through travel agents, search engines, tour operators, airlines, airports, hotels, cars and railways.\\r\\nWe have developed our technology in partnership with the travel industry for over 30 years. We combine a deep understanding of how people travel with the ability to design and deliver the most complex, trusted, critical systems our customers need. In 2019, we helped connect over 1.9 billion people to local travel providers in over 190 countries. We help connect over 1.6 billion people a year to local travel providers in over 190 countries.\\r\\n

      We are one company, with a global mindset and a local presence wherever our customers need us.

      \\r\\n

      Our purpose is to shape the future of travel. We are passionate in our pursuit of better technology that makes better journeys.

      \\r\\nAmadeus is an IBEX 35 company, listed on the Spanish Stock Exchange under AMS.MC. The company has also been recognized by the Dow Jones Sustainability Index for the last ten years.\\r\\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1540-web.png"},"website":"https://amadeus.com/en","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1541,"name":"Scheidt & Bachmann System Technik GmbH","member_since":"2021-11-29","renewal_date":"2026-12-01","description":{"long":"

      System manufacturer for software and hardware systems for control and safety technology for the railway domain. Innovative solutions for control and administration of rail-bound traffic.

      \\r\\n

      The developers at the site in Kiel-Melsdorf complement the SIL 4 signalling-department of Mönchengladbach, Germany, with the ZSB2000 interlocking system and the BUES2000 level-crossing. This especially includes complex traffic-control-systems for large international inter-city-railways and metro-customers (on basis of the control centers of the DB Netz AG, the product Travis and the train detection system ZNP801D), an operation and interlocking simulation (\\\"Betriebs- und Stellwerkssimulation\\\", BEST), next to a modern tooling ecosystem for supporting planning, configuration, development and quality assurance.

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1541-web.png"},"website":"https://www.scheidt-bachmann.de/de/signalling-systems/home","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1542,"name":"Nokia","member_since":"2021-11-29","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1542-web.jpg"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Strategic Member","level":"WGSD","working_group":"orc"}],"is_active_member":true},{"organization_id":1543,"name":"AURA","member_since":"2021-12-16","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1544,"name":"Data Intelligence Offensive (DIO)","member_since":"2021-12-21","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1545,"name":"Frontgrade Gaisler","member_since":"2021-12-21","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1545-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1547,"name":"Array","member_since":"2022-01-05","renewal_date":"2027-01-01","description":{"long":"Array is a law firm dedicated to IT matters, with a specific focus on Free and Open Source Software and other field of open technology, data, science and society. Founded by Carlo Piana, a renown lawyer and advocate in the FOSS space since early 2000's, it includes high-quality experts in the field and mentioned by the Who's Who Legal for IT in Italy. The members of Array have a deep knowledge of the legal and technical aspects of the IT world. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1547-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"f348c2873ca8ed8e9eca","description":"Guest Member","level":"WGSAP","working_group":"oniro"}],"is_active_member":true},{"organization_id":1550,"name":"Accenture GmbH","member_since":"2022-02-04","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1550-web.png"},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1551,"name":"Capgemini","member_since":"2022-02-15","renewal_date":"2027-02-01","description":{"long":"Capgemini is a global leader in partnering with companies to transform and manage their business by harnessing the power of technology. The Group is guided everyday by its purpose of unleashing human energy through technology for an inclusive and sustainable future. It is a responsible and diverse organization of over 325,000 team members more than 50 countries. With its deep industry expertise, Capgemini is trusted by its clients to address the entire breadth of their business needs, from strategy and design to operations, fueled by the innovative world of cloud, data, AI, connectivity, software, digital engineering and platforms. The Group reported in 2021 global revenues of €18 billion."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1551-web.jpg"},"website":"https://www.capgemini.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f348c2873ca8ed8e9eca","description":"Supporting Member","level":"WGSM","working_group":"oniro"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1553,"name":"ZF Friedrichshafen AG","member_since":"2022-02-25","renewal_date":"2027-03-01","description":{"long":" ZF is a global technology company supplying systems for passenger cars, commercial vehicles and industrial technology, enabling the next generation of mobility. ZF allows vehicles to see, think and act. In the four technology domains of Vehicle Motion Control, Integrated Safety, Automated Driving, and Electric Mobility, ZF offers comprehensive product and software solutions for established vehicle manufacturers and newly emerging transport and mobility service providers. ZF electrifies a wide range of vehicle types. With its products, the company contributes to reducing emissions, protecting the climate and enhancing safe mobility."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1553-web.png"},"website":"https://www.zf.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1554,"name":"AUMOVIO Germany GmbH","member_since":"2022-02-28","renewal_date":"2027-03-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1554-web.png"},"website":"https://www.aumovio.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1555,"name":"Reycom AG, a Swiss corporation","member_since":"2022-02-28","renewal_date":"2027-03-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1555-web.png"},"website":"https://www.reycom.swiss/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1559,"name":"ZettaScale Technology SARL","member_since":"2022-03-03","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1559-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Leader Member","level":"WGLM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1561,"name":"ESOP- Empresas SW OS Portuguesas","member_since":"2022-03-25","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1566,"name":"Sustainable Digital Infrastructure Alliance","member_since":"2022-05-11","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1568,"name":"ETAS GmbH","member_since":"2022-05-25","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1568-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1570,"name":"CARIAD SE","member_since":"2022-05-31","renewal_date":"2026-06-01","description":{"long":"CARIAD is an automotive software company in the Volkswagen Group that develops a leading tech stack for the automotive industry with the mission to make the automotive experience safer, more sustainable and more comfortable in a new way – for everyone, everywhere. \nCARIAD builds a uniform software platform for all brands of Volkswagen Group, which includes a unified and scalable architecture, an operating system and automotive cloud. CARIAD’s Headquarter is located in Germany, and co-operates with international Volkswagen Group teams in the US and China. \n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1570-web.png"},"website":"https://cariad.technology/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1571,"name":"Omnifish OU","member_since":"2022-06-24","renewal_date":"2026-07-01","description":{"long":"At OmniFish, we specialize in providing professional services for Jakarta EE technologies. Our seasoned team of experts excels in Java application development and Java middleware production support. As dedicated contributors to the Eclipse GlassFish project and active members of the Jakarta EE Working Group, we are committed to modernizing the GlassFish server and contributing to Jakarta EE specifications. Customer success is our top priority. We work closely with our clients and partners to help them craft exceptional applications and services, ensuring our customers a safe journey filled with joy. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1571-web.png"},"website":"https://omnifish.ee","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1572,"name":"Elektrobit Automotive GmbH","member_since":"2022-07-05","renewal_date":"2026-07-01","description":{"long":"Elektrobit is an award-winning and visionary global vendor of embedded and connected software products and services for the automotive industry. A leader in automotive software with over 35 years serving the industry, Elektrobit's software powers over five billion devices in more than 600 million vehicles and offers flexible, innovative solutions for car infrastructure software, connectivity & security, automated driving and related tools, and user experience. Elektrobit is a wholly-owned, independently-operated subsidiary of Continental."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1572-web.png"},"website":"https://www.elektrobit.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1575,"name":"Dipartimento di Elettronica, Informazione e Bioingegneria - Politecnico di Milano","member_since":"2022-07-28","renewal_date":"2026-08-01","description":{"long":"The Dipartimento di Elettronica, Informazione e Bioingengeria of the Politecnico di Milano is one of the largest European ICT departments. With nearly 1000 members, researchers, collaborators, PhD students, and technical and administrative staff, the Department is a vital institution capable of promoting education, fundamental and applied research, and technology transfer to companies. The six department sections bring together consolidated competencies in systems and control, computer science and engineering, electronics, telecommunications, bioengineering, and electrical engineering."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1575-web.png"},"website":"https://www.deib.polimi.it/ita/home","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"f348c2873ca8ed8e9eca","description":"Guest Member","level":"WGSAP","working_group":"oniro"}],"is_active_member":true},{"organization_id":1579,"name":"Shenzhen Ping An Communication Technology Co.,Ltd","member_since":"2022-08-11","renewal_date":"2026-08-01","description":{"long":"We are a technology solution expert of Ping An group\n\nPractice the corporate mission of \"science and technology enable finance and science and technology drive ecology\"\n\nEmpowering the group's financial services, medical and health services, automobile services, and smart city ecosystem construction\n\nCommitted to becoming an international leading technology company"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1579-web.png"},"website":"https://tech.pingan.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1580,"name":"Bloomberg L.P.","member_since":"2022-08-23","renewal_date":"2026-09-01","description":{"long":"Bloomberg is a global leader in business and financial information, delivering trusted data, news, and insights that bring transparency, efficiency, and fairness to markets. The company helps connect influential communities across the global financial ecosystem via reliable technology solutions that enable our customers to make more informed decisions and foster better collaboration. Our 7,000+ engineers, developers, data scientists and technologists are the ones who make this happen, creating and advancing solutions and systems that solve complex, real-world problems for customers across the global capital markets."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1580-web.png"},"website":"https://www.TechAtBloomberg.com/opensource","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Enterprise Member","level":"WGDSA","working_group":"adoptium"}],"is_active_member":true},{"organization_id":1582,"name":"FUJIFILM Italia S.p.A","member_since":"2022-09-02","renewal_date":"2026-09-01","description":{"long":"FUJIFILM Italia - Medical Informatics Research & Development Unit\nMain activities of the Unit are Technological Research in the IT field, Design and Development of Software Products and Applications, Consulting on Digital Solutions for the Healthcare."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1582-web.png"},"website":"https://www.fujifilm.com/it/en/about/us/offices/fujifilm-italia-unita-operativa-locale-di-bolzano","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1584,"name":"Harvey Mudd College","member_since":"2022-09-09","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1584-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1587,"name":"Oklahoma State University","member_since":"2022-09-13","renewal_date":"2026-09-01","description":{"long":"Oklahoma State University is a public land-grant research university in Stillwater, Oklahoma, United States. The university was established in 1890 under the legislation of the Morrill Act."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1587-web.png"},"website":"https://go.okstate.edu/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1588,"name":"PlanV GmbH","member_since":"2022-09-16","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1588-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1589,"name":"T-Systems International GmbH","member_since":"2022-09-20","renewal_date":"2026-09-01","description":{"long":"With locations in more than 20 countries and over 27,000 employees (December 31, 2022), as well as annual revenues of around EUR 4.0 billion (2022), T-Systems is one of the leading providers of digital services in Europe. The Deutsche Telekom subsidiary is headquartered in Germany and has a presence in Europe as well as in selected core markets and strategic production locations. T-Systems offers integrated end-to-end IT solutions, driving the digital transformation of companies in all industries and the public sector. T-Systems’ focus industries are automotive, the public sector, healthcare and transport. For these areas, T-Systems develops industry-specific solutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1589-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1591,"name":"Universidad de Cantabria","member_since":"2022-09-23","renewal_date":"2026-08-01","description":{"long":"

      The University of Cantabria (UC) offers official university study courses in the self-governed region of Cantabria (Spain).

      \n\n

      The Software Engineering and Real-Time Group (Ingeniería del Software y Tiempo Real, ISTR) has kept a continuous research activity in the theory and application of Software Engineering to Distributed Embedded Real-Time Systems, Model-Driven Engineering, Databases and Business Intelligence, and Security in Information Systems. The group also actively participates in the development of standards: Real-time POSIX operating systems, the UML-MARTE profile of OMG, and the standardization process of the Ada language.

      "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1591-web.jpg"},"website":"https://web.unican.es/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1592,"name":"Google LLC","member_since":"2022-10-12","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1592-web.png"},"website":"","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"},{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1594,"name":"Quantyss","member_since":"2022-10-18","renewal_date":"2026-10-01","description":{"long":"QUANTYSS is a startup company created to share senior expertise to innovative entrepreneurs of SMEs, startups and midcaps, in the field of technology. We provide specialized insight and relevant industry expertise to help them take their business further.\nWe are actively driving, together with Eclipse members, the Edge Computing Working Group of the French Embedded France Association. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1594-web.png"},"website":"https://quantyss.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1595,"name":"Rivos Inc","member_since":"2022-10-18","renewal_date":"2026-10-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1595-web.png"},"website":"https://www.rivosinc.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Strategic Member","level":"WGSD","working_group":"adoptium"}],"is_active_member":true},{"organization_id":1597,"name":"Kentyou","member_since":"2022-10-25","renewal_date":"2026-11-01","description":{"long":"Kentyou is an innovative startup company helping cities in their digital transformation to face their environmental social and economic challenges more efficiently. By leveraging the open source Eclipse sensiNact platform, it provides a data hub that collects data from various data sources including IoT, mobile apps and open data portals, unifies and analyses that data to extract actionable information. Kentyou also provides a visualisation and impact monitoring tool to help cities making data-driven decisions with desirable effects with the help of emerging AI technologies. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1597-web.jpg"},"website":"https://kentyou.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"68db2919ffe553250ae8","description":"Participant Member","level":"WGAPS","working_group":"osgi"}],"is_active_member":true},{"organization_id":1599,"name":"SOTEC GmbH+Co KG","member_since":"2022-11-02","renewal_date":"2026-11-01","description":{"long":"SOTEC is an internationally active provider of software development and hardware solutions for the retail, automotive, industrial automation, manufacturing, and energy industries. SOTEC has been supporting its customers with advanced technology and development services for over 40 years. Services range from specialized hardware and embedded systems development to cloud architectures and solution implementations.\nAs a specialist for IoT (IIoT), Machine Learning, Industrie 4.0 and Cloud technologies, SOTEC supports customers in building digital platforms and thus in the digital transformation of their companies."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1599-web.png"},"website":"https://www.sotec.eu/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1600,"name":"Open Elements GmbH","member_since":"2022-11-08","renewal_date":"2026-12-01","description":{"long":"Open Elements is an IT company whose main focus is on the two points of Open Source Software (OSS) and Java. By focusing on these two points, we can provide our customers with expert advice and support in the development and use of Open Source Software. By specializing in Java-based OSS, we are members of the leading committees and foundations on these topics and actively contribute to the further development of critical open source systems in the Java ecosystem."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1600-web.png"},"website":"https://open-elements.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"32c5a745df264aa2a809","description":"Participant Member","level":"WGAPS","working_group":"adoptium"},{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1604,"name":"Stellenbosch University","member_since":"2022-12-01","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Guest Member","level":"WGSAP","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1605,"name":"Micro Stream Software GmbH","member_since":"2022-12-16","renewal_date":"2026-12-01","description":{"long":"MicroStream connects Java seamlessly with the cloud. To do this, we create new innovations in Java, the JVM ecosystem, Android, data storage, and the cloud and work on standards together with other vendors and the strong open-source community. \n\nOur business is to support companies and organizations that use open source for their mission-critical projects commercially with enterprise add-ons, extended testing, custom-builds, first-class enterprise-grade support, and manpower."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1605-web.png"},"website":"https://microstream.one/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1606,"name":"Schaeffler","member_since":"2022-12-20","renewal_date":"2027-05-01","description":{"long":"The Schaeffler Group has been driving forward groundbreaking inventions and developments in the field of motion technology for over 75 years. With innovative technologies, products, and services for electric mobility, CO2-efficient drives, chassis solutions and renewable energies, the company is a reliable partner for making motion more efficient, intelligent, and sustainable – over the entire life cycle. We pioneer motion."},"logos":{"print":"https://membership.eclipse.org/organization/images/1606-print.eps","web":"https://membership.eclipse.org/organization/images/1606-web.png"},"website":"https://www.schaeffler.de","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1607,"name":"Valeo","member_since":"2022-12-20","renewal_date":"2027-01-01","description":{"long":"https://www.valeo.com/en/"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1607-web.png"},"website":"https://www.valeo.com/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1608,"name":"Cummins Inc","member_since":"2023-01-05","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1608-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1609,"name":"N3uron Connectivity Systems","member_since":"2023-01-10","renewal_date":"2027-01-01","description":{"long":"N3uron software is an Industrial Edge Platform for IIoT and DataOps that streamlines the flow of data between industrial systems and business applications, either on-premise or in the cloud. N3uron provides an out-of-the-box solution for data standardization, normalization and contextualization, seamless integration with industrial and IT systems, efficient information management, and unparalleled scalability and security. The N3uron platform makes it easier for operations teams to aggregate, manage and analyze industrial data, resulting in enhanced productivity and informed decision-making."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1609-web.png"},"website":"https://n3uron.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"f351fc9ba96cb468393f","description":"Participant Member","level":"WGAPS","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1611,"name":"NOUVELLE-AQUITAINE OPEN SOURCE","member_since":"2023-01-16","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1612,"name":"IAV ","member_since":"2023-01-18","renewal_date":"2027-02-01","description":{"long":"As one of the globally leading engineering partners, IAV develops the mobility of the future. Regardless of the specific manufacturer, our engineering proves itself in vehicles and technologies all over the world.\n\nWith more than 35 years of experience and an unsurpassed range of expertise, we combine the best of many different worlds: automotive and IT, hardware and software, products and services. With our workforce of more than 7,600 employees and first-class technical resources, we help our customers to implement their projects, from the concept right through to SOP. Our goal: better mobility.\n\nIAV offers outstanding engineering expertise and combines the best of many different worlds.\n\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1612-web.png"},"website":"https://www.iav.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1613,"name":"10xEngineers","member_since":"2023-01-24","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1613-web.jpg"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1614,"name":"SCANOSS","member_since":"2023-01-26","renewal_date":"2027-02-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1614-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1616,"name":"Start North ry","member_since":"2023-02-02","renewal_date":"2027-02-01","description":{"long":"Start North accelerates the learning and implementation of the latest technology in order to improve the productivity of companies and promote the world's sustainable development. Together with its university and business partners, Start North plans and implements programs and projects and implements 5G Mokki Tech Space learning, innovation, remote work and service environments for university campuses and wherever know-how, work and services are needed."},"logos":{"print":null,"web":null},"website":"https://www.startnorth.com/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1619,"name":"Gaia-x European Association for Data and Cloud.","member_since":"2023-02-27","renewal_date":"2027-03-01","description":{"long":"The Gaia-X European Association for Data and Cloud AISBL\nInnovation through digital sovereignty – that’s the goal of Gaia-X. We achieve this by establishing an ecosystem in which data is made available, collated and shared in a trustworthy environment. The users always retain sovereignty over their data. So, what emerges is not a cloud but a federated system that links many cloud services providers and users together."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1619-web.png"},"website":"https://gaia-x.eu","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1620,"name":"Beijing Institute of Open Source Chip","member_since":"2023-03-16","renewal_date":"2026-08-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1620-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1621,"name":"LG Electronics, Inc","member_since":"2023-03-21","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1621-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1625,"name":"Open Forum Europe AISBL","member_since":"2023-04-13","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1625-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1629,"name":"Posit Software, PBC","member_since":"2023-05-04","renewal_date":"2027-05-01","description":{"long":"Posit helps people understand and improve the world through data. We build tools that enable robust and reproducible data analysis through a code-first approach, paired with tools that make it easy to share insights. Our core software is open source, freely available to anyone. Our professional software equips individuals and teams to develop and share their work at scale."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1629-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"}],"is_active_member":true},{"organization_id":1630,"name":"Reutlingen University","member_since":"2023-05-10","renewal_date":"2027-05-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1630-web.png"},"website":"https://www.reutlingen-university.de","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1631,"name":"Litmus Automation Inc.","member_since":"2023-05-11","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1631-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Participant Member","level":"WGAPS","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1632,"name":"Qualcomm Innovation Center","member_since":"2023-05-24","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1632-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1633,"name":"KU Leuven","member_since":"2023-06-12","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1633-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1634,"name":"Ferdinand-Steinbeis-Institut","member_since":"2023-06-14","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1634-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1635,"name":"Energy Telecommunications & Electrical Association","member_since":"2023-06-28","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1635-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Guest Member","level":"WGSAP","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1636,"name":"Politecnico di Torino","member_since":"2023-07-06","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1638,"name":"Integration Objects","member_since":"2023-10-02","renewal_date":"2026-10-01","description":{"long":"Integration Objects empowers businesses to accelerate their digital transformation through robust and reliable solutions. We offer a wide range of applications including, Industrial IoT (IIoT), cyber security, Big Data Analytics, C4ISR, and process automation for Defense and Governmental Institutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1638-web.png"},"website":"https://integrationobjects.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"},{"document_id":"f351fc9ba96cb468393f","description":"Participant Member","level":"WGAPS","working_group":"sparkplug"}],"is_active_member":true},{"organization_id":1640,"name":"GPS BY DESIGN CENTRE","member_since":"2023-10-12","renewal_date":"2026-10-01","description":{"long":"Our mission is to spread the word on how to operationalize Privacy by Design, especially given its inclusion in the new E.U. General Data Protection Regulation. "},"logos":{"print":null,"web":null},"website":"https://gpsbydesigncentre.com/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1641,"name":"International Data Spaces e. V","member_since":"2023-11-02","renewal_date":"2026-10-01","description":{"long":"The International Data Spaces Association (IDSA) is on a mission to create the future of the global, digital economy. Its 170+ member companies and institutions have created the International Data Spaces (IDS) standard: a secure system of sovereign and trusted data sharing in which all participants can realize the full value of their data. IDS enables new smart services and innovative business processes to work across companies and industries while ensuring that the control of data remains in the hands of data providers. We call this data sovereignty."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1641-web.jpg"},"website":"https://internationaldataspaces.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1642,"name":"PX5","member_since":"2023-11-03","renewal_date":"2026-11-01","description":{"long":"Expert Professional Support for THREADX RTOS and middleware!\n\nWith decades of THREADX domain experience, our team delivers professional, fully ticketed, and tracked support for individual projects through entire enterprises. Being the original authors, nobody knows the THREADX technology more than us. We are committed to taking care of you!\n\nhttps://rtosx.com\n\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1642-web.png"},"website":"https://rtosx.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1643,"name":"iSHARE Foundation","member_since":"2023-11-08","renewal_date":"2026-11-01","description":{"long":"Non-profit trust and participant governance framework for data exchange between organisations in data spaces. Bringing organisational and trust interoperability. \n\nTrust derived from Legal, Operational and Technical credentials and specifications. \n\nGoverned by the data spaces that build on iSHARE and licence the specifications and operational and legal documentation to govern data spaces. "},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1643-web.jpg"},"website":"https://ishare.eu","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1645,"name":"Amazon Europe Core SARL","member_since":"2023-11-16","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1645-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"b557cbcb3973aac1beae","description":"Participant Member","level":"WGAPS","working_group":"open-vsx"}],"is_active_member":true},{"organization_id":1646,"name":"Cypherbridge Systems LLC","member_since":"2023-11-15","renewal_date":"2026-11-01","description":{"long":"Cypherbridge develops and deploys purpose-built IoT security software solutions to meet industry standards, regulation, and cybersecurity requirements throughout the product lifecycle.\n\t\nFrom concept to product, Cypherbridge delivers solutions for Eclipse ThreadX platforms, including secure boot, connectivity, security, and IoT Cloud Computing. We offer SDKPac for Eclipse ThreadX, porting and design services, and long term technical support for complete solution delivery and software lifecycle."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1646-web.jpg"},"website":"https://www.cypherbridge.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Supporter Member","level":"WGSM","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1648,"name":"co4e GmbH","member_since":"2024-01-01","renewal_date":"2027-01-01","description":{"long":"The Consultancy for Engineers (co4e) GmbH is a software tool vendor and consultancy service provider. It was founded in 2019 as a spin-off from the German Aerospace Center (DLR). The co4e GmbH head office located in the heart of Berlin (Kreuzberg), Germany.

      Established with a vision to address the complexities of transportation systems, we bring together a team of experts and enthusiasts who are passionate about creating sustainable, efficient, and intelligent mobility solutions. At the heart of our endeavors are SESAM, a cloud platform designed for mobility simulations, and ASSIST, a tool suite to automate the design of safety-critical systems."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1648-web.png"},"website":"https://www.co4e.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1649,"name":"Sonatype Inc.","member_since":"2023-12-07","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1649-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1651,"name":"Johannes Kepler University Linz","member_since":"2023-12-12","renewal_date":"2027-01-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1651-web.png"},"website":"https://www.jku.at","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1653,"name":"Nordic Institute for Interoperability Solutions","member_since":"2024-01-05","renewal_date":"2027-01-01","description":{"long":"Nordic Institute for Interoperability Solutions (NIIS) ensures the development and strategic management of digital government solutions that allow NIIS members to provide excellent digital public services.\n\nNIIS is both a network and cooperation platform and executioner of IT developments in members’ common interests. The institute focuses on practical collaboration, sharing of experience and promoting innovation. The operating model of the institute is something unique in the world.\n\nThe republics of Estonia, Finland and Iceland are members of NIIS, and the Faroe Islands and the Government of Åland are partners of NIIS."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1653-web.png"},"website":"https://www.niis.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1654,"name":"Harman International","member_since":"2024-01-08","renewal_date":"2027-01-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1654-web.jpg"},"website":"https://www.harman.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1655,"name":"The Matrix.org Foundation C.I.C.","member_since":"2024-01-19","renewal_date":"2027-02-01","description":{"long":"Matrix is an open protocol for decentralised, secure communications. The Matrix.org Foundation exists to act as a neutral custodian for Matrix and to nurture it as efficiently as possible as a single unfragmented standard, for the greater benefit of the whole ecosystem, not benefiting or privileging any single player or subset of players."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1655-web.png"},"website":"https://matrix.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1656,"name":"Catena-X Automotive Network e.V","member_since":"2024-02-06","renewal_date":"2027-01-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1656-web.png"},"website":"https://catena-x.net/en/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1659,"name":"Lunatech Labs B.V.","member_since":"2024-02-27","renewal_date":"2027-03-01","description":{"long":"Lunatech, established in 1993, is a distinguished software development consultancy renowned for its expertise in crafting tailored solutions to address intricate challenges. Specialising in the design, development, deployment, and ongoing operation of custom software, Lunatech excels in delivering comprehensive services.\n\nWith a team of experts proficient in Java and Scala, Lunatech excels in various domains including system integration, legacy transformation, and continuous maintenance. With three decades of experience under our belt, we have empowered our clients to streamline their IT operations and achieve their business objectives seamlessly."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1659-web.png"},"website":"https://www.lunatech.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1661,"name":"FEV.io GmbH","member_since":"2026-03-01","renewal_date":"2027-02-01","description":{"long":""},"logos":{"print":"https://membership.eclipse.org/organization/images/1661-print.eps","web":"https://membership.eclipse.org/organization/images/1661-web.png"},"website":"https://www.fev.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1663,"name":"Instituto Tecnológico de Informática","member_since":"2024-03-12","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1663-web.jpg"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1666,"name":"Stadt Jena","member_since":"2024-03-21","renewal_date":"2027-04-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1666-web.png"},"website":"https://www.jena.de","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1667,"name":"TOSIT Association","member_since":"2024-03-25","renewal_date":"2027-04-01","description":{"long":"TOSIT (The Open Source I Trust) is an association under the French Law of 1901 of major end-users, with the following aims:\n\n* Provide a forum for its members to meet and discuss Open Source solutions\n\n* Encourage the sharing of feedback and best practice in Open Source\n\n* Gather and identify the needs of its members in terms of Open Source solutions\n\n* Carry out strategic or technical studies and monitoring related to Open Source solutions\n\n* Promote Open Source solutions judged to be the most effective in various areas of interest\n\n* Carry out communication and publication initiatives related to Open Source \n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1667-web.png"},"website":"https://tosit.fr","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1669,"name":"Ferrous Systems GmbH","member_since":"2024-04-08","renewal_date":"2027-05-01","description":{"long":"Ferrous Systems is worlds leading Rust company. From tooling, to support, to training. They are the first one to implement and certify a fully open source Rust compiler usable in safety, by ISO 26262 and IEC 61508.\n\nMembers of the company have been in Rust Foundation and Rust Project leadership for a long while."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1669-web.png"},"website":"https://ferrous-systems.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1670,"name":"Rust Foundation","member_since":"2024-04-11","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1670-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1672,"name":"DIN e.V.","member_since":"2024-04-30","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1673,"name":"Python Software Foundation","member_since":"2024-05-01","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1673-web.jpg"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1674,"name":"The PHP Foundation (Open Source Collective)","member_since":"2024-05-06","renewal_date":"2027-05-01","description":{"long":"We support, advance, and develop the PHP Language."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1674-web.png"},"website":"https://thephp.foundation","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1675,"name":"OpenSSL Software Foundation Inc","member_since":"2024-05-22","renewal_date":"2027-05-01","description":{"long":"The OpenSSL Foundation works to ensure that everyone, including nonprofits, academics, and independent developers, has access to fundamental data privacy and security tools that are the backbone of internet protection, quietly safeguarding millions of users. We do this to help build a safer internet — one that serves the public interest and upholds privacy and security as foundational rights."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1675-web.png"},"website":"https://openssl-foundation.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1676,"name":"OWASP Foundation, Inc.","member_since":"2024-05-26","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1676-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1677,"name":"THE COMETBID SOFTWARE FOUNDATION","member_since":"2024-05-30","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1678,"name":"XITASO GmbH","member_since":"2024-06-03","renewal_date":"2026-06-01","description":{"long":"As a digitization partner and expert for high-end software engineering, XITASO provides advice to B2B customers, identifies digitization potentials, optimizes business processes and create digital strategies and solutions. Based on an agile mindset, we design and develop individual solutions with outstanding expertise in the areas of Industry 4.0, Internet of Things (IoT), Robotics, Digital Twin, Data Science, Artificial Intelligence and Augmented Reality. XITASO serves customers throughout Germany from various industries, in particular from mechanical and plant engineering as well as the healthcare sector."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1678-web.png"},"website":"https://xitaso.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1679,"name":"Michelin","member_since":"2024-06-06","renewal_date":"2026-06-01","description":{"long":"Michelin is building a world-leading manufacturer of life-changing composites and experiences.\n\nPioneering engineered materials for more than 130 years, Michelin is uniquely positioned to make decisive contributions to human progress and a more sustainable world."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1679-web.png"},"website":"https://www.michelin.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1680,"name":"Stichting Blender Foundation","member_since":"2024-06-06","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1680-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1681,"name":"Clever Cloud SAS","member_since":"2024-06-06","renewal_date":"2026-06-01","description":{"long":"Founded in 2010, Clever Cloud is a French company based in Nantes, specialising in IT automation. It creates and supplies the software building blocks needed to deploy applications on self-service PaaS architectures. Its customers include such big names as Airbus, Great Place to Work, MAIF, Cegid, Docaposte, Fairphone, Solocal and TBWA."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1681-web.png"},"website":"https://www.clever.cloud/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1682,"name":"CodeDay","member_since":"2024-06-06","renewal_date":"2026-06-01","description":{"long":"There's a place in tech for everyone. CodeDay is a non-profit providing welcoming, hands-on opportunities for under-served students to explore a future in tech and beyond through opportunities to contribute to open-source software."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1682-web.png"},"website":"https://www.codeday.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"},{"document_id":"fb4d6a3ddca7cfc1de0d","description":"Guest Member","level":"WGSAP","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1683,"name":"ZHAW, Institute of Mechatronic Systems (IMS)","member_since":"2024-06-13","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1684,"name":"The Document Foundation","member_since":"2024-06-13","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1684-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1685,"name":"Open Infrastructure Foundation","member_since":"2024-06-17","renewal_date":"2026-06-01","description":{"long":"The Open Infrastructure Foundation (previously known as the OpenStack Foundation) is a global non-profit organization providing a neutral, open environment for organizations, developers, and users to build open source infrastructure software together.\n\nStrong of more than 110,000 individual members representing 700+ organizations in 180+ countries, our Foundation is the home for several open source infrastructure projects, including OpenStack, Kata Containers and StarlingX."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1685-web.png"},"website":"https://openinfra.dev","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1686,"name":"Stichting NLnet Labs","member_since":"2024-06-19","renewal_date":"2026-06-01","description":{"long":"Founded in 1999, NLnet Labs is an independent, non-profit, public benefit foundation based in the Netherlands. Our mission is to make the core of the Internet a better, safer place by developing open-source software, through applied research and by promoting and contributing to open standards."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1686-web.png"},"website":"https://nlnetlabs.nl","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1688,"name":"FreeBSD Foundation","member_since":"2024-06-26","renewal_date":"2026-07-01","description":{"long":"The FreeBSD Foundation is a 501(c)(3) non-profit organization supporting the FreeBSD Project and community. Accepting donations from individuals and businesses, the Foundation uses funds to develop features, employ software engineers, improve build and test infrastructure, advocate for FreeBSD through in-person and online events, and provide training and educational material. Representing the FreeBSD Project in legal affairs, the Foundation is the recognized entity for contracts, licenses, and other legal arrangements and is entirely donation-supported. Learn more at freebsdfoundation.org"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1688-web.png"},"website":"https://www.freebsdfoundation.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1689,"name":"Yildiz Technical University","member_since":"2024-06-26","renewal_date":"2026-07-01","description":{"long":"Established in 1911, Yildiz Technical University (YTU) is one of Turkey's oldest and most prestigious technical universities. With around 35,000 students and over 1,500 academic staff, YTU offers interdisciplinary programs in engineering, natural sciences, social sciences, and arts. Our modern campus supports student-centered learning, enriched by student clubs and research facilities. Internationally recognized for research, YTU collaborates on various national and global projects, aiming to advance education, research, and innovation to tackle global challenges."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1689-web.png"},"website":"https://www.yildiz.edu.tr/en","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1690,"name":"useblocks GmbH","member_since":"2024-06-26","renewal_date":"2026-07-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1690-web.png"},"website":"https://useblocks.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1691,"name":"3DS Outscale","member_since":"2024-06-26","renewal_date":"2026-06-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1693,"name":"Qorix GmbH","member_since":"2024-07-08","renewal_date":"2026-07-01","description":{"long":"Qorix is a leading provider of middleware software and engineering services with a specialized focus on the\nautomotive industry. Our offerings are:\n1- Qorix Classic stack\n2- Qorix Adaptive stack\n3- Qorix Performance stack\n4- Qorix Developer: Designer & SDK\n5- Engineering Services: maintenance, support & customization."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1693-web.png"},"website":"https://www.qorix.ai/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1695,"name":"L&T Technology Services Ltd","member_since":"2024-08-22","renewal_date":"2026-09-01","description":{"long":"L&T Technology Services Limited (LTTS) is a global leader in Engineering and R&D (ER&D) services. With 1,343 patents filed for 57 of the Global Top 100 ER&D spenders, LTTS lives and breathes engineering. Our innovations speak for themselves – World’s 1st Autonomous Welding Robot, Solar ‘Connectivity’ Drone, and the Smartest Campus in the World, to name a few.\nLTTS’ expertise in engineering design, product development, smart manufacturing, and digitalization touches every area of human lives. With 108 Innovation and R&D design centers globally, we specialize in disruptive technology spaces such as NexGen Comms, Artificial Intelligence, Digital Factory, and Autonomous Transport."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1695-web.jpg"},"website":"https://www.ltts.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1696,"name":"Allison Transmission, Inc.","member_since":"2024-08-22","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1696-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1697,"name":"ekxide IO GmbH","member_since":"2024-09-04","renewal_date":"2026-10-01","description":{"long":"ekxide is the innovative force behind iceoryx and iceoryx2. Founded by the core maintainers and creators of iceoryx, the company was established to propel the development and ensure the continued success of the open-source project. ekxide provides a range of services focused on iceoryx, including commercial extensions and tooling, accelerated development, safety certification, priority bug-fixing, and expert training and consulting. These services are designed to enhance the performance, reliability, and safety of iceoryx-based solutions. ekxide supports clients with tailored solutions to meet their specific needs in this area."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1697-web.png"},"website":"https://ekxide.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1698,"name":"Instituto de Telecomunicações","member_since":"2024-09-06","renewal_date":"2026-09-01","description":{"long":"Instituto de Telecomunicações (IT) is a private, not-for-profit organization, of public interest, a partnership of nine institutions with research and development in the field of Telecommunications.\n\nIT is actively involved in fundamental and applied research both at national and international levels. IT also plays its role towards public society with public awareness initiatives, knowledge transfer to industry, and by providing consulting services on a non-competing basis."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1698-web.png"},"website":"https://it.pt","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1699,"name":"I Machines, Inc","member_since":"2024-09-09","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1699-web.jpg"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1700,"name":"Ruby Central, Inc.","member_since":"2024-09-09","renewal_date":"2026-09-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1700-web.jpg"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1702,"name":"Ejad for Engineering Systems","member_since":"2024-09-13","renewal_date":"2026-09-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1702-web.jpg"},"website":"https://www.ejad.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1703,"name":"Software Heritage Foundation - Inria Foundation","member_since":"2024-09-20","renewal_date":"2026-10-01","description":{"long":"Software Heritage is a non-profit initiative dedicated to collecting, preserving, and sharing all publicly available source code for the long term. Launched by Inria, supported by UNESCO, Software Heritage operates as the largest archive of open-source software, hosting over 50 billion software artifacts. Its mission is to ensure that software, a vital part of our digital heritage, is safeguarded and accessible to future generations. By enabling traceability and fostering collaboration, Software Heritage serves as an invaluable resource for research, industry, and society at large."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1703-web.png"},"website":"https://softwareheritage.org","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1704,"name":"Open Source Initiative","member_since":"2024-09-23","renewal_date":"2026-10-01","description":{"long":"The OSI is the authority that defines Open Source, recognized globally by individuals, companies, and by public institutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1704-web.jpg"},"website":"https://opensource.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1705,"name":"Ostfalia University","member_since":"2024-10-15","renewal_date":"2026-10-01","description":{"long":"The Faculty of Computer Science has existed for 30 years and has grown continuously with 24 professors and over 1000 students. Our range of courses includes courses that require typical on-campus study as well as courses that are offered in a purely online format. At the Faculty of Computer Science one can study five Bachelor programs and two Master degree programs. The online format offers two Bachelor and two Master degree programs."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1705-web.png"},"website":"https://www.ostfalia.de/cms/de/i/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"8d438deac670301c236d","description":"Guest Member","level":"WGSAP","working_group":"microprofile"},{"document_id":"e3985a1aead45e62ef7b","description":"Guest Member","level":"WGSAP","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1707,"name":"Tekniker","member_since":"2024-10-24","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1708,"name":"Navigation Data Standard (NDS) e.V.","member_since":"2024-10-24","renewal_date":"2026-11-01","description":{"long":"The NDS Association provides the global standard for map data within automotive ecosystems. Its members include car manufacturers, application developers, compiler developers, as well as map and service providers.\n\nThe NDS.Live standard enables the transmission of dynamic, cloud-connected data. It addresses the increasing size of map data by ensuring that only necessary updates are transmitted over data connections. NDS.Live has a highly modular architecture and supports various types of data, making it adaptable for a range of automotive applications."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1708-web.png"},"website":"https://nds-association.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1709,"name":"Acatech - Deutsche Akademie der Technikwissenschaften e.V.","member_since":"2024-10-31","renewal_date":"2026-11-01","description":{"long":""},"logos":{"print":null,"web":null},"website":"https://www.acatech.de/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1710,"name":"AboutCode Europe ASBL","member_since":"2024-11-05","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1710-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1711,"name":"KPIT Technologies Ltd","member_since":"2024-11-08","renewal_date":"2026-11-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1711-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1713,"name":"Cyberismo","member_since":"2024-11-25","renewal_date":"2026-12-01","description":{"long":"Cyberismo is a cybersecurity solution company dedicated to fortifying the digital landscape. We base our approach on the open-source Cyberismo solution, open collaboration, cybersecurity consulting, and the courage to focus on delivering impactful results. We simplify and optimise cybersecurity management while aiding teams in integrating cybersecurity into their daily operations."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1713-web.png"},"website":"https://cyberismo.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1714,"name":"OpenNebula Systems SL","member_since":"2024-12-03","renewal_date":"2027-01-01","description":{"long":"First released in Spain in 2008 as the outcome of a research project, OpenNebula has evolved into the main European open source cloud & edge management platform. As a Virtualized Infrastructure Manager (VIM) and IaaS solution, it unifies support for virtual machines, containers, and Kubernetes clusters, while providing federation, multi-tenancy, and automated provisioning across datacenter, cloud, and edge environments."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1714-web.png"},"website":"https://opennebula.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1716,"name":"Tauri","member_since":"2024-12-17","renewal_date":"2027-01-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1719,"name":"Double Open","member_since":"2024-12-20","renewal_date":"2027-01-01","description":{"long":"Double Open combines specialized compliance knowledge with the transparency of the industry's leading open toolset."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1719-web.png"},"website":"https://www.doubleopen.io","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1720,"name":"Welotec GmbH","member_since":"2024-12-20","renewal_date":"2027-01-01","description":{"long":"Founded in 1969 with headquarters in Germany, Welotec boasts a strong team with a deep understanding of the needs of machine builders. We specialize in Edge Computing, Cloud Integration, and are committed to Open Source solutions."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1720-web.png"},"website":"https://www.welotec.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1721,"name":"GEA Group AG","member_since":"2024-12-20","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1721-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1722,"name":"Codethink Ltd.","member_since":"2025-01-02","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1722-web.png"},"website":"","levels":[{"level":"SD","description":"Strategic Member","sort_order":"500"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1723,"name":"Vates","member_since":"2024-12-19","renewal_date":"2027-01-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1724,"name":"Erlang Ecosystem Foundation","member_since":"2025-01-06","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1724-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1726,"name":"Overnet Solutions S.r.l","member_since":"2025-01-24","renewal_date":"2027-02-01","description":{"long":"With over 30 years of experience in ICT training, Overnet is a leader in Italy’s ICT education sector. We offer the broadest range of official IT training and continuously update our programs to address all aspects of digital transformation. Companies and professionals looking to excel in the tech evolution trust us to develop their digital skills.\n\nOvernet is your fast track to Open Source Cloud Adoption. Our solutions enable your team to seamlessly adopt open source technologies across existing and new cloud providers, embracing hybrid and portable cloud workloads."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1726-web.png"},"website":"https://overnet.education/open-source-cloud-adoption","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1728,"name":"Associação 101010","member_since":"2025-01-30","renewal_date":"2027-02-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1729,"name":"Transcality AG","member_since":"2025-02-06","renewal_date":"2027-02-01","description":{"long":"We build a digital replica of traffic to evaluate the present and plan the future."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1729-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1736,"name":"Cofinity-X GmbH","member_since":"2025-02-18","renewal_date":"2027-03-01","description":{"long":"Cofinity-X is a joint venture established by several major companies, including BMW, Mercedes-Benz, SAP, BASF and ZF, to create a secure and efficient data exchange network in the automotive industry. This initiative aims to address the growing need for seamless and secure data sharing among automotive manufacturers, suppliers and other stakeholders. Cofinity-X represents a significant step forward in addressing the complexities and challenges of data management in the modern industry. Its collaborative approach and use of cutting-edge technology position it as a key player in the future of data exchange."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1736-web.png"},"website":"https://www.cofinity-x.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1737,"name":"Hyundai Mobis","member_since":"2025-02-20","renewal_date":"2027-03-01","description":{"long":"As a global auto parts vendor, we focus on autonomous driving, connectivity and electrification to be a leader in the era of smart mobility. Based on three modular auto components (i.e. chassis, cockpit and front-end), we work to make driving safer and easier and also offer service parts that can best serve the purpose.\n\nOur vision is to be a provider of differentiated mobility solutions that combine software and hardware in the upcoming mobility industry. To make this vision a reality, we have expanded our business areas to include smart mobility, UAM and robotics based on our R&D capability and production capacity."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1737-web.png"},"website":"https://www.mobis.com/en/index.do","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1738,"name":"Ant Blockchain Technology (Shanghai) Co., Ltd","member_since":"2025-02-26","renewal_date":"2027-03-01","description":{"long":"Ant Digital Technology is an independent section of Ant Group's technology commercialization, which began independent operations in April 2024. Ant Digital Technology started with Ant Chain and has the world's largest number of leading technologies and patents in the blockchain field. In addition, it has continuously developed multiple commercial product brands, including ZOLOZ, mPaaS, SofaStack, Ant Shield, and Ant Tianjian.As of now, Ant Digital Technology has collaborated with over 300 partners to serve more than 10,000 enterprise customers."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1738-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1740,"name":"Universidad Politécnica de Madrid","member_since":"2025-02-27","renewal_date":"2027-03-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1740-web.png"},"website":"https://upm.es","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Guest Member","level":"WGSAP","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1741,"name":"Drupal Association","member_since":"2025-02-27","renewal_date":"2027-03-01","description":{"long":"The Drupal Association is the non-profit organization focused on accelerating Drupal, fostering the growth of the Drupal community, and supporting the project’s vision to create a safe, secure, and open web for everyone. The Drupal Association also administers Drupal.org on behalf of the Drupal community."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1741-web.png"},"website":"https://www.drupal.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1742,"name":"Capabilities Limited","member_since":"2025-03-05","renewal_date":"2027-03-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1742-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1744,"name":"Debian France","member_since":"2025-03-20","renewal_date":"2027-04-01","description":{"long":null},"logos":{"print":null,"web":null},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1745,"name":"APELL ASBL","member_since":"2025-04-03","renewal_date":"2027-04-01","description":{"long":"APELL – The European Open Source Software Business Association is the umbrella organisation for national Open Source business associations in Europe. Founded in 2020, it aims to increase opportunities for the members of the Association’s member organisations, and to raise awareness for the strategic importance of Open Source for Europe. APELL promotes a sovereign, in­clu­sive, ethical digital market."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1745-web.png"},"website":"https://apell.info/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1746,"name":"the School of ECE of NTUA","member_since":"2025-04-09","renewal_date":"2027-04-01","description":{"long":"School of Electrical and Computer Engineering of the National Technical University of Athens"},"logos":{"print":null,"web":null},"website":"https://www.ece.ntua.gr/en","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1747,"name":"Liebherr-Digital Development Center GmbH","member_since":"2025-04-23","renewal_date":"2027-04-01","description":{"long":"The Liebherr Group is a family-run technology company with a highly diversified product programme. The company is one of the largest construction equipment manufacturers in the world. It also provides high-quality, user-oriented products and services in a wide range of other areas. The Liebherr Group includes over 150 companies across all continents. In 2023, it employed more than 50,000 staff and achieved combined revenues of over 14 billion euros."},"logos":{"print":"https://membership.eclipse.org/organization/images/1747-print.eps","web":"https://membership.eclipse.org/organization/images/1747-web.png"},"website":"https://www.liebherr.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1748,"name":"The IO Foundation","member_since":"2025-04-24","renewal_date":"2027-05-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1748-web.png"},"website":"","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1749,"name":"EGI Foundation","member_since":"2025-05-06","renewal_date":"2026-06-01","description":{"long":"The EGI Foundation is the coordinating body of the EGI Federation. It offers a federation and management platform that enables service providers to harmonise interfaces and connect to a common hub.\nThe EGI Federation is the scalable digital infrastructure resulting from this coordination, serving thousands of researchers across disciplines. It provides advanced computing and data analytics capabilities through hundreds of public and private service providers, offering distributed computing, storage solutions, co-development opportunities, expert support, and training to propel scientific collaboration and innovation."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1749-web.png"},"website":"https://www.egi.eu","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"},{"document_id":"df911e0adcad1a1c51df","description":"Guest Member","level":"WGSAP","working_group":"asciidoc"}],"is_active_member":true},{"organization_id":1751,"name":"Stichting Connekt","member_since":"2025-05-09","renewal_date":"2027-05-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Strategic Member","level":"WGSD","working_group":"dataspace"}],"is_active_member":true},{"organization_id":1752,"name":"Open Source Matters Inc.","member_since":"2025-06-11","renewal_date":"2026-06-01","description":{"long":"Open Source Matters (OSM) is a not-for-profit organisation, incorporated in the United States, created to serve the financial and legal interests of the Joomla project. OSM has been designed to be flexible and change as the needs of Joomla! expand. At all times, OSM is fashioned to suit the needs of the Joomla project. OSM will also engage in regular self-assessment to ensure it is accountable to Joomla!, acting in Joomla!'s interest and ensuring that it is the right shape and size to support Joomla!."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1752-web.png"},"website":"https://www.joomla.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1754,"name":"GitHub","member_since":"2025-07-08","renewal_date":"2026-07-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1754-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1755,"name":"Engineering Ingegneria Informatica","member_since":"2025-07-22","renewal_date":"2026-08-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1755-web.png"},"website":"https://eng.it/en","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1756,"name":"ONERA DTIS","member_since":"2025-07-24","renewal_date":"2026-08-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1758,"name":"ifrOSS","member_since":"2025-09-02","renewal_date":"2026-09-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1760,"name":"Validas AG","member_since":"2025-09-09","renewal_date":"2026-09-01","description":{"long":"Validas is the driving force behind safe tools, libraries, and basic software. For 25 years, we have been supporting our international customers from the automotive, aerospace, and semiconductor industries with the qualification of tools, libraries, and basic software, as well as powerful qualification kits for code generators, compilers, and simulators. This ensures that the software used in cars, airplanes, or complex technical systems meets the highest safety requirements and common safety standards such as ISO 26262 or IEC 61508."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1760-web.png"},"website":"https://www.validas.de/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[],"is_active_member":true},{"organization_id":1761,"name":"Open Source Society Malta","member_since":"2025-09-24","renewal_date":"2026-09-01","description":{"long":"OSSMalta.eu is the premier open source community in Malta, fostering collaboration and knowledge-sharing. It promotes the adoption of open source technologies through educational initiatives and community building. As a member of the Eclipse Foundation's Open Regulatory Compliance Working Group (ORC WG), OSSMalta contributes to developing best practices and guidelines for open source actors to meet evolving regulatory requirements, such as those from the European Cyber Resilience Act. This membership reinforces our commitment to ensuring open source remains a viable and compliant option for developers and businesses across Europe."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1761-web.png"},"website":"https://ossmalta.eu","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1762,"name":"Brightskies","member_since":"2025-10-02","renewal_date":"2026-10-01","description":{"long":"Brightskies is a digital transformation enabler and market leader founded in 2012 with more than 400 employees. With over a decade of experience working closely with more than 50 clients, we guarantee exceptional results to help your business succeed and stand out.\nOur Automotive Services team has very strong experience developing safety-critical automotive systems to most of the car makers around the globe from the classical car makers where safety, security and certification represent the core principals to the disruptive ones where performance, technology and software-defined features are the main theme."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1762-web.png"},"website":"https://brightskiesinc.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1763,"name":"RT-RK DOO Novi Sad","member_since":"2025-10-06","renewal_date":"2026-10-01","description":{"long":"RT-RK is a premium embedded engineering company with over 30 years of experience and 600+ engineers. We help global leaders in the automotive, consumer electronics, and semiconductor industries turn complex ideas into dependable real-time systems. With expertise in both hardware and software development, RT-RK provides scalable technology and resource solutions that enable faster innovation, higher efficiency, and products built to perform at scale."},"logos":{"print":"https://membership.eclipse.org/organization/images/1763-print.eps","web":"https://membership.eclipse.org/organization/images/1763-web.png"},"website":"https://rt-rk.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1764,"name":"ZIUR Foundation","member_since":"2025-10-14","renewal_date":"2026-10-01","description":{"long":"Industrial Cybersecurity Center of Gipuzkoa\nWe are a public initiative created by the Gipuzkoa Provincial Council to help industrial companies reinforce their protection and that of their products or services against cyberattacks.\n\nWe live in a connected world that advances at a great speed. From ZIUR we help you go through that road of opportunities and threats with greater security.\n\nWe want to promote greater safety barriers against cyberthreats in the industrial field, to revitalize the sector of cybersecurity and to contribute to the competitiveness of the companies of our territory"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1764-web.png"},"website":"https://www.ziur.eus","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"},{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1767,"name":"Infosys Limited","member_since":"2025-10-27","renewal_date":"2026-11-01","description":{"long":""},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1767-web.png"},"website":"https://infosys.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1768,"name":"SignPath Foundation","member_since":"2025-11-10","renewal_date":"2026-11-01","description":{"long":"The SignPath Foundation supports open source projects by providing code signing certificates and a secure signing process through SignPath.io. We verify that binaries are built from the project’s public repository, eliminating the need for personal identity checks. Private keys are securely generated and stored on our HSM, enabling simple integration into automated build pipelines. Our goal is to make trustworthy software delivery accessible to OSS projects, and all services are free of charge."},"logos":{"print":"https://membership.eclipse.org/organization/images/1768-print.eps","web":"https://membership.eclipse.org/organization/images/1768-web.png"},"website":"https://signpath.org/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Foundation Member","level":"WGFDN","working_group":"orc"}],"is_active_member":true},{"organization_id":1769,"name":"WirelessCar","member_since":"2025-11-17","renewal_date":"2026-11-01","description":{"long":"WirelessCar is a leading innovator of digital vehicle services, accelerating the transformation toward software-defined mobility. With over 25 years of experience, we turn connected vehicle data into business value through scalable, cloud-based solutions spanning connectivity, journey intelligence, safety, and EV services. Connecting more than 17 million vehicles in over 100 countries, WirelessCar collaborates with global OEMs and industry partners to leverage the full value of connected services to empower future mobility."},"logos":{"print":"https://membership.eclipse.org/organization/images/1769-print.eps","web":"https://membership.eclipse.org/organization/images/1769-web.jpg"},"website":"https://www.wirelesscar.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1770,"name":"Libelium","member_since":"2025-11-18","renewal_date":"2026-11-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Participant Member","level":"WGAPS","working_group":"dataspace"},{"document_id":"efcdef5b284754c43de2","description":"Participant Member","level":"WGAPS","working_group":"orc"}],"is_active_member":true},{"organization_id":1771,"name":"mtrail Deutschland GmbH","member_since":"2025-11-24","renewal_date":"2026-11-01","description":{"long":"mtrail GmbH is a specialized Swiss engineering and software company that develops technology solutions for the international railway industry. Their services focus on traffic management, infrastructure modeling, and AI-based image recognition, notably through products like \"TrainVision\" and the \"RCS\" (Rail Control System) family. They cater primarily to major European railway operators and infrastructure managers, including Swiss Federal Railways (SBB), Deutsche Bahn (DB), and Infrabel."},"logos":{"print":"https://membership.eclipse.org/organization/images/1771-print.eps","web":"https://membership.eclipse.org/organization/images/1771-web.jpg"},"website":"http://www.mtrail.de","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fb4d6a3ddca7cfc1de0d","description":"","level":"WGSM","working_group":"eclipse-ide"}],"is_active_member":true},{"organization_id":1775,"name":"Openchip & Software Technologies S.L.","member_since":"2025-12-11","renewal_date":"2026-12-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1776,"name":"TRATON AB","member_since":"2025-12-21","renewal_date":"2027-01-01","description":{"long":"With its brands Scania, MAN, International, and Volkswagen Truck & Bus, the TRATON GROUP is one of the world’s leading commercial vehicle manufacturers. The Group’s product portfolio comprises trucks, buses, and light-duty commercial vehicles. “Transforming Transportation Together. For a sustainable world.”: this intention underlines the Company’s ambition to have a lasting and sustainable impact on the commercial vehicle business and on the Group’s commercial growth."},"logos":{"print":"https://membership.eclipse.org/organization/images/1776-print.eps","web":"https://membership.eclipse.org/organization/images/1776-web.png"},"website":"https://traton.com/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Strategic Member","level":"WGSD","working_group":"sdv"}],"is_active_member":true},{"organization_id":1777,"name":"LG CNS","member_since":"2025-12-21","renewal_date":"2026-12-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1777-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"e3985a1aead45e62ef7b","description":"Participant Member","level":"WGAPS","working_group":"jakarta-ee"}],"is_active_member":true},{"organization_id":1778,"name":"Fondazione CHIPS-IT","member_since":"2026-01-02","renewal_date":"2027-01-01","description":{"long":null},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1778-web.png"},"website":"","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1779,"name":"Associação TICE.PT","member_since":"2026-01-05","renewal_date":"2027-01-01","description":{"long":"TICE.PT is the Portuguese national cluster for Information, Communication, and Electronic Technologies, bringing together companies, universities, research centers, and other relevant entities in the sector. Officially recognized since 2009, the cluster acts as a collaborative platform that promotes innovation, knowledge transfer, and technological development, strengthening the competitiveness of the digital economy in Portugal.\n\nThrough cooperation among its members, TICE.PT seeks to enhance the national technological offering, support research and development projects, stimulate the creation of innovative products and services, and boost the internationalization of Portuguese companies."},"logos":{"print":"https://membership.eclipse.org/organization/images/1779-print.eps","web":"https://membership.eclipse.org/organization/images/1779-web.jpg"},"website":"https://tice.pt/en","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"1921b2dfac4cc9b00ad6","description":"Guest Member","level":"WGSAP","working_group":"dataspace"},{"document_id":"598b0ec4df9dcbb23499","description":"Guest Member","level":"WGSAP","working_group":"internet-things-iot"}],"is_active_member":true},{"organization_id":1780,"name":"Nilux GmbH","member_since":"2026-01-07","renewal_date":"2027-01-01","description":{"long":"Nilux GmbH is a Germany-based automotive software partner driving the transition toward Software-Defined Vehicles. We enable OEMs and Tier-1s to evolve from legacy, ECU-centric systems to scalable SDV architectures through AUTOSAR Classic & Adaptive, middleware, vehicle abstraction, cloud integration, and automotive cybersecurity. As an Eclipse SDV supporting member, Nilux positions itself as a pioneer service partner for SDV strategy, migration, and industrialization, translating open-source SDV innovation into production-ready, safety-compliant vehicle platforms."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1780-web.png"},"website":"https://nilux-gmbh.de/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1781,"name":"lowRISC C.I.C.","member_since":"2026-01-19","renewal_date":"2027-02-01","description":{"long":"Open Silicon Everywhere™\n\nlowRISC® C.I.C. (Community Interest Company) is a regulated not-for-profit company with a mission to help make open-source silicon a reality, commercially relevant, and widely adopted throughout the industry. \nWe aim to bring to semiconductors the enormous benefits that open-source already provides to software: transparency, reuse and collaboration.\n"},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1781-web.png"},"website":"https://lowrisc.org/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1782,"name":"ACTIA Group","member_since":"2026-01-21","renewal_date":"2027-02-01","description":{"long":"Founded in 1986, ACTIA Group is a mid-sized, family-owned international company designing and manufacturing electronic systems for demanding sectors including mobility, aerospace, space and energy. ACTIA supports its customers throughout the full product lifecycle, from design to production and services. The Group delivers robust, high-performance and competitive solutions, with strong industrial capabilities and supply chain expertise. Its organization enables responsiveness and execution across international markets, making ACTIA a reliable partner for complex electronic programs."},"logos":{"print":"https://membership.eclipse.org/organization/images/1782-print.eps","web":"https://membership.eclipse.org/organization/images/1782-web.png"},"website":"https://www.actia.com","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1784,"name":"AINekko, Co.","member_since":"2026-02-24","renewal_date":"2027-03-01","description":{"long":"Ainekko develops RISC-V–based compute platforms for AI applications on the edge and contributes to the open hardware ecosystem through collaboration with the OpenHW Group and the broader RISC-V community."},"logos":{"print":"https://membership.eclipse.org/organization/images/1784-print.eps","web":"https://membership.eclipse.org/organization/images/1784-web.png"},"website":"https://nekko.ai/","levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1785,"name":"Appraid-tech","member_since":"2026-02-24","renewal_date":"2027-03-01","description":{"long":""},"logos":{"print":"https://membership.eclipse.org/organization/images/1785-print.eps","web":"https://membership.eclipse.org/organization/images/1785-web.png"},"website":"https://www.appraid-tech.com/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Guest Member","level":"WGSAP","working_group":"sdv"}],"is_active_member":true},{"organization_id":1786,"name":"Applied Intuition Inc.","member_since":"2026-02-25","renewal_date":"2027-03-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Supporting Member","level":"WGSM","working_group":"sdv"}],"is_active_member":true},{"organization_id":1788,"name":"42dot Inc.","member_since":"2026-03-09","renewal_date":"2027-03-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"fbb9be0bc283dc584b23","description":"Participant Member","level":"WGAPS","working_group":"sdv"}],"is_active_member":true},{"organization_id":1789,"name":"Beijing Academy of Artificial Intelligence (BAAI)","member_since":"2026-03-10","renewal_date":"2027-03-01","description":{"long":"Beijing Academy of Artificial Intelligence(BAAI) is a non-profit new research and development institution established in November 2018. It is committed to becoming a leader in artificial intelligence innovation, creating the best academic and technological innovation ecosystem globally, tackling the most fundamental and critical problems, and serving as the source of academic ideas, basic theories, top talents, enterprise innovation, and development policies for artificial intelligence worldwide, thereby promoting sustainable development for humanity, the environment, and intelligence."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1789-web.png"},"website":"https://www.baai.ac.cn","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1790,"name":"Open Culture Foundation","member_since":"2026-04-09","renewal_date":"2027-04-01","description":{"long":"Open Culture Foundation is a non-profit organization. Through promoting open technology and cross-field collaboration, we continue to connect tech communities and other public and private entities in Taiwan. By doing so, we work to promote open co-creation and protect digital rights, and thereby support a more transparent and inclusive digital civil society.\nSince 2014, we have functioned as a legal entity and supported over 30 open technology communities in Taiwan. Throughout this process, we have not only continued to promote the idea of open technology, we have also become involved in policy advocacy and spoken up for the public's digital rights."},"logos":{"print":null,"web":"https://membership.eclipse.org/organization/images/1790-web.png"},"website":"https://ocf.tw/en/","levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[{"document_id":"efcdef5b284754c43de2","description":"Guest Member","level":"WGSAP","working_group":"orc"}],"is_active_member":true},{"organization_id":1791,"name":"Mosaic SoC","member_since":"2026-04-14","renewal_date":"2027-04-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"ecd63e75a561bffe2ffc","description":"Participant Member","level":"WGAPS","working_group":"openhw-foundation"}],"is_active_member":true},{"organization_id":1792,"name":"Fundación para la Transparencia del Software","member_since":"2026-04-16","renewal_date":"2027-04-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AS","description":"Associate Member","sort_order":"100"}],"wgpas":[],"is_active_member":true},{"organization_id":1793,"name":"AUTOSOL, LP","member_since":"2026-05-07","renewal_date":"2027-05-01","description":null,"logos":{"print":null,"web":null},"website":null,"levels":[{"level":"AP","description":"Contributing Member","sort_order":"200"}],"wgpas":[{"document_id":"f351fc9ba96cb468393f","description":"Strategic Member","level":"WGSD","working_group":"sparkplug"}],"is_active_member":true}] \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Code Cache/js/index-dir/the-real-index b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Code Cache/js/index-dir/the-real-index index a71290d..7cace5f 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Code Cache/js/index-dir/the-real-index and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Code Cache/js/index-dir/the-real-index differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DIPS b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DIPS index cd010b2..055e107 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DIPS and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DIPS differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DIPS-wal b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DIPS-wal index 8c8188e..3c9a386 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DIPS-wal and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DIPS-wal differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DawnGraphiteCache/data_1 b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DawnGraphiteCache/data_1 index a0957ea..97f2854 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DawnGraphiteCache/data_1 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DawnGraphiteCache/data_1 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DawnWebGPUCache/data_1 b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DawnWebGPUCache/data_1 index 62d956a..9cd92b6 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DawnWebGPUCache/data_1 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/DawnWebGPUCache/data_1 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Extension State/LOG.old b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Extension State/LOG.old index f438ea6..a7f1fbf 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Extension State/LOG.old +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Extension State/LOG.old @@ -1,3 +1,3 @@ -2026/05/10-01:32:20.887 2aa0 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Extension State/MANIFEST-000001 -2026/05/10-01:32:20.887 2aa0 Recovering log #3 -2026/05/10-01:32:20.888 2aa0 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Extension State/000003.log +2026/05/11-17:52:04.774 3008 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Extension State/MANIFEST-000001 +2026/05/11-17:52:04.775 3008 Recovering log #3 +2026/05/11-17:52:04.775 3008 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Extension State/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/GPUCache/data_1 b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/GPUCache/data_1 index f29b340..2f4e882 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/GPUCache/data_1 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/GPUCache/data_1 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/History b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/History index c2f024b..c0df537 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/History and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/History differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/000003.log b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/000003.log index dacf3f2..8ac4a90 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/000003.log and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/000003.log differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/LOG b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/LOG index 58be978..e69de29 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/LOG +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/LOG @@ -1,3 +0,0 @@ -2026/05/10-18:30:40.011 292c Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Local Storage\leveldb/MANIFEST-000001 -2026/05/10-18:30:40.021 292c Recovering log #3 -2026/05/10-18:30:40.022 292c Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Local Storage\leveldb/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/LOG.old b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/LOG.old index ec86aee..ff43aef 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/LOG.old +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Local Storage/leveldb/LOG.old @@ -1,3 +1,3 @@ -2026/05/10-01:32:20.890 744 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Local Storage\leveldb/MANIFEST-000001 -2026/05/10-01:32:20.897 744 Recovering log #3 -2026/05/10-01:32:20.898 744 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Local Storage\leveldb/000003.log +2026/05/11-17:52:04.805 22c0 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Local Storage\leveldb/MANIFEST-000001 +2026/05/11-17:52:04.891 22c0 Recovering log #3 +2026/05/11-17:52:04.918 22c0 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Local Storage\leveldb/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Network/TransportSecurity b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Network/TransportSecurity index 088abd0..7692e8f 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Network/TransportSecurity +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Network/TransportSecurity @@ -1 +1 @@ -{"sts":[{"expiry":1809887691.64094,"host":"Bb6CfwBW9xa4G2DyhI27lujzIm9QMX4njeP0qgg7n+Y=","mode":"force-https","sts_include_subdomains":true,"sts_observed":1778351691.640946},{"expiry":1809966643.589161,"host":"5AUdaPrjbZpycMJSfvB4F6jmmAfkjR133lCOp+js4+E=","mode":"force-https","sts_include_subdomains":true,"sts_observed":1778430643.589164},{"expiry":1809887692.184129,"host":"6Rxq1ifSWlOJhzOYYdWRhfgKRZ4jrGi2e5lJ0HKREHQ=","mode":"force-https","sts_include_subdomains":true,"sts_observed":1778351692.184138}],"version":2} \ No newline at end of file +{"sts":[{"expiry":1810050726.011535,"host":"Bb6CfwBW9xa4G2DyhI27lujzIm9QMX4njeP0qgg7n+Y=","mode":"force-https","sts_include_subdomains":true,"sts_observed":1778514726.011542},{"expiry":1810123191.276278,"host":"5AUdaPrjbZpycMJSfvB4F6jmmAfkjR133lCOp+js4+E=","mode":"force-https","sts_include_subdomains":true,"sts_observed":1778587191.276281},{"expiry":1809887692.184129,"host":"6Rxq1ifSWlOJhzOYYdWRhfgKRZ4jrGi2e5lJ0HKREHQ=","mode":"force-https","sts_include_subdomains":true,"sts_observed":1778351692.184138}],"version":2} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Preferences b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Preferences index 91da2c1..31d45d7 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Preferences +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Preferences @@ -1 +1 @@ -{"aadc_info":{"age_group":3},"accessibility":{"captions":{"headless_caption_enabled":false}},"account_tracker_service_last_update":"13422911690305312","autocomplete":{"retention_policy_last_version":147},"autofill":{"edge_autofill_advanced_ml_enabled":false,"edge_autofill_purge_low_quality_profiles_by_timeline":false,"last_version_deduped":147},"bookmark":{"storage_computation_last_update":"13422911690303915"},"browser":{"available_dark_theme_options":"All","recent_theme_color_list":[4293914607.0,4293914607.0,4293914607.0,4293914607.0,4293914607.0],"show_toolbar_edge_generic_sidebar_button":false,"theme":{"color_scheme2":2},"user_level_features_context":{}},"browser_content_container_height":67,"browser_content_container_width":183,"browser_content_container_x":0,"browser_content_container_y":0,"commerce_daily_metrics_last_update_time":"13422911690304426","countryid_at_install":18772,"credentials_enable_service":false,"edge":{"bookmarks":{"last_dup_info_record_time":"13422825300291938"},"msa_sso_info":{"allow_for_non_msa_profile":true},"profile_sso_info":{"is_msa_first_profile":true,"msa_sso_algo_state":1},"services":{"signin_scoped_device_id":"3165f288-04ad-476d-92d1-abea48bbc919"}},"edge_journeys":{"latest_journeys_count":0},"edge_rewards":{"cache_data":"CAA=","coachmark_promotions":{},"hva_promotions":[],"hva_webui_action_status_dict":{},"refresh_status_muted_until":"13423430090265996"},"edge_ux_config":{"assignmentcontext":"","dataversion":"0","experimentvariables":{},"flights":{}},"edge_vpn":{"available":true},"edge_wallet":{"passwords":{"password_lost_report_date":"13422825320278890"}},"enterprise_profile_guid":"c9c307cc-82a2-4be9-89c0-04edbd9e6415","extension":{"installed_extension_count":2},"extensions":{"alerts":{"initialized":true},"chrome_url_overrides":{},"last_chrome_version":"147.0.3912.98","pdf_upsell_triggered":false,"pinned_extension_migration":true,"pinned_extensions":[]},"fsd":{"retention_policy_last_version":147},"gaia_cookie":{"periodic_report_time_2":"13422911690272491"},"intl":{"selected_languages":"en-GB,en,en-US"},"language_dwell_time_average":{"en":19375.166666666668,"it":3.0},"language_model_counters":{"en":11,"it":1},"language_usage_count":{"en":6,"it":1},"media":{"engagement":{"schema_version":5}},"migrated_user_scripts_toggle":true,"muid":{"last_sync":"13422911690304680","values_seen":[]},"optimization_guide":{"hintsfetcher":{"hosts_successfully_fetched":{}},"previously_registered_optimization_types":{"ABOUT_THIS_SITE":true,"AUTOFILL_ACTOR_IFRAME_ORIGIN_ALLOWLIST":true,"GLIC_ACTION_PAGE_BLOCK":true,"HISTORY_CLUSTERS":true,"LOADING_PREDICTOR":true,"MERCHANT_TRUST_SIGNALS_V2":true,"PAGE_ENTITIES":true,"PRICE_TRACKING":true,"SALIENT_IMAGE":true,"SAVED_TAB_GROUP":true,"V8_COMPILE_HINTS":true}},"password_manager":{"account_store_backup_password_cleaning_last_timestamp":"13422825350282160","account_store_migrated_to_os_crypt_async":true,"profile_store_backup_password_cleaning_last_timestamp":"13422825350282713","profile_store_migrated_to_os_crypt_async":true},"personalization_data_consent":{"personalization_in_context_consent_can_prompt":true,"personalization_in_context_count":0},"privacy_sandbox":{"first_party_sets_data_access_allowed_initialized":true},"profile":{"avatar_index":20,"background_password_check":{"check_fri_weight":9,"check_interval":"2592000000000","check_mon_weight":6,"check_sat_weight":6,"check_sun_weight":6,"check_thu_weight":9,"check_tue_weight":9,"check_wed_weight":9,"next_check_time":"13424909115774370"},"content_settings":{"exceptions":{"3pcd_heuristics_grants":{},"abusive_notification_permissions":{},"access_to_get_all_screens_media_in_session":{},"anti_abuse":{},"app_banner":{},"ar":{},"are_suspicious_notifications_allowlisted_by_user":{},"auto_picture_in_picture":{},"auto_select_certificate":{},"automatic_downloads":{},"automatic_fullscreen":{},"autoplay":{},"background_sync":{},"bluetooth_chooser_data":{},"bluetooth_guard":{},"bluetooth_scanning":{},"camera_pan_tilt_zoom":{},"captured_surface_control":{},"clear_browsing_data_cookies_exceptions":{},"client_hints":{},"clipboard":{},"controlled_frame":{},"cookie_controls_metadata":{"file:///*,*":{"last_modified":"13422987294856216","setting":{}},"https://[*.]eclipse.org,*":{"last_modified":"13422904240321357","setting":{}}},"cookies":{},"direct_sockets":{},"direct_sockets_private_network_access":{},"display_media_system_audio":{},"disruptive_notification_permissions":{},"durable_storage":{},"edge_ad_targeting":{},"edge_ad_targeting_data":{},"edge_all_file_read_access":{},"edge_browser_action":{},"edge_sdsm":{},"edge_split_screen":{},"edge_tech_scam_detection":{},"edge_u2f_api_request":{},"edge_user_agent_token":{},"fedcm_idp_registration":{},"fedcm_idp_signin":{},"fedcm_share":{},"file_system_access_chooser_data":{},"file_system_access_extended_permission":{},"file_system_access_restore_permission":{},"file_system_last_picked_directory":{},"file_system_read_guard":{},"file_system_write_guard":{},"formfill_metadata":{},"geolocation":{},"geolocation_with_options":{},"hand_tracking":{},"has_migrated_local_network_access":true,"hid_chooser_data":{},"hid_guard":{},"http_allowed":{},"https_enforced":{},"idle_detection":{},"images":{},"important_site_info":{},"initialized_translations":{},"intent_picker_auto_display":{},"javascript":{},"javascript_jit":{},"javascript_optimizer":{},"keyboard_lock":{},"legacy_cookie_access":{},"legacy_cookie_scope":{},"local_fonts":{},"local_network":{},"local_network_access":{},"loopback_network":{},"media_engagement":{"https://www.eclipse.org:443,*":{"expiration":"13430677242302836","last_modified":"13422901242302841","lifetime":"7776000000000","setting":{"hasHighScore":false,"lastMediaPlaybackTime":0.0,"mediaPlaybacks":0,"visits":3}}},"media_stream_camera":{},"media_stream_mic":{},"midi_sysex":{},"mixed_script":{},"nfc_devices":{},"notification_interactions":{},"notification_permission_review":{},"notifications":{},"ondevice_languages_downloaded":{},"password_protection":{},"payment_handler":{},"permission_actions_history":{},"permission_autoblocking_data":{},"permission_autorevocation_data":{},"pointer_lock":{},"popups":{},"protected_media_identifier":{},"protocol_handler":{},"reduced_accept_language":{},"safe_browsing_url_check_data":{},"secure_network":{},"secure_network_sites":{},"sensors":{},"serial_chooser_data":{},"serial_guard":{},"site_engagement":{"https://www.eclipse.org:443,*":{"last_modified":"13422985902453009","setting":{"lastEngagementTime":1.342295710245282e+16,"lastShortcutLaunchTime":0.0,"pointsAddedToday":0.0,"rawScore":11.7105321135}}},"sleeping_tabs":{},"sound":{},"speaker_selection":{},"ssl_cert_decisions":{},"storage_access":{},"storage_access_header_origin_trial":{},"subresource_filter":{},"subresource_filter_data":{},"suspicious_notification_ids":{},"suspicious_notification_show_original":{},"top_level_storage_access":{},"trackers":{},"trackers_data":{},"tracking_org_exceptions":{},"tracking_org_relationships":{},"typosquatting":{},"unused_site_permissions":{},"usb_chooser_data":{},"usb_guard":{},"vr":{},"web_app_installation":{},"webid_api":{},"webid_auto_reauthn":{},"window_placement":{}},"pref_version":1},"created_by_version":"147.0.3912.98","creation_time":"13422825290227113","default_content_setting_values":{"has_migrated_local_network_access":true},"edge_password_is_using_new_login_db_path":false,"edge_password_login_db_path_flip_flop_count":0,"edge_profile_id":"a229742e-1a76-40e7-b7b9-b0cbc2f225f1","edge_user_with_non_zero_passwords":false,"exit_type":"Normal","has_seen_signin_fre":false,"is_relative_to_aad":false,"last_engagement_time":"13422957102452820","last_time_obsolete_http_credentials_removed":1778351750.282291,"last_time_password_store_metrics_reported":1778351720.277159,"managed_user_id":"","name":"Profile 1","network_pbs":{},"observed_session_time":{"feedback_rating_in_product_help_observed_session_time_key_147.0.3912.98":7.0},"password_hash_data_list":[],"signin_fre_seen_time":"13422825290260630","were_old_google_logins_removed":true},"reset_prepopulated_engines":false,"safety_hub":{"unused_site_permissions_revocation":{"migration_completed":true}},"saved_tab_groups":{"did_enable_shared_tab_groups_in_last_session":false,"specifics_to_data_migration":true},"sessions":{"event_log":[{"crashed":false,"time":"13422825290268704","type":0},{"did_schedule_command":false,"first_session_service":true,"tab_count":1,"time":"13422825356403533","type":2,"window_count":1},{"crashed":false,"time":"13422843140823994","type":0},{"did_schedule_command":false,"first_session_service":true,"tab_count":3,"time":"13422843168919448","type":2,"window_count":3},{"crashed":false,"time":"13422904239947130","type":0},{"did_schedule_command":false,"first_session_service":true,"tab_count":3,"time":"13422905046795006","type":2,"window_count":3}],"session_data_status":1},"signin":{"accounts_metadata_dict":{},"allowed":true},"spellcheck":{"dictionaries":["en-GB"]},"syncing_theme_prefs_migrated_to_non_syncing":true,"tab_search":{"pinned_to_tabstrip":false,"pinned_to_tabstrip_migration_complete":true},"total_passwords_available_for_account":0,"total_passwords_available_for_profile":0,"translate_site_blacklist":[],"translate_site_blocklist_with_time":{},"typosquatting":{"allowlist_migration_done":true},"user_experience_metrics":{"personalization_data_consent_enabled_last_known_value":false},"webrtc":{"udp_port_range":"0-0"}} \ No newline at end of file +{"aadc_info":{"age_group":3},"accessibility":{"captions":{"headless_caption_enabled":false}},"account_tracker_service_last_update":"13423001237298263","autocomplete":{"retention_policy_last_version":147},"autofill":{"edge_autofill_advanced_ml_enabled":false,"edge_autofill_purge_low_quality_profiles_by_timeline":false,"last_version_deduped":147},"bookmark":{"storage_computation_last_update":"13423001237298449"},"browser":{"available_dark_theme_options":"All","recent_theme_color_list":[4293914607.0,4293914607.0,4293914607.0,4293914607.0,4293914607.0],"show_toolbar_edge_generic_sidebar_button":false,"theme":{"color_scheme2":2},"user_level_features_context":{}},"browser_content_container_height":135,"browser_content_container_width":339,"browser_content_container_x":0,"browser_content_container_y":0,"commerce_daily_metrics_last_update_time":"13423001237299261","countryid_at_install":18772,"credentials_enable_service":false,"edge":{"bookmarks":{"last_dup_info_record_time":"13422988334590120"},"msa_sso_info":{"allow_for_non_msa_profile":true},"profile_sso_info":{"is_msa_first_profile":true,"msa_sso_algo_state":1},"services":{"signin_scoped_device_id":"9d99cb2d-9037-4213-b239-f879b7cdfbc4"}},"edge_journeys":{"latest_journeys_count":0},"edge_rewards":{"cache_data":"CAA=","coachmark_promotions":{},"hva_promotions":[],"hva_webui_action_status_dict":{},"refresh_status_muted_until":"13423430090265996"},"edge_ux_config":{"assignmentcontext":"","dataversion":"0","experimentvariables":{},"flights":{}},"edge_vpn":{"available":true},"edge_wallet":{"passwords":{"password_lost_report_date":"13422988354565399"}},"enterprise_profile_guid":"c9c307cc-82a2-4be9-89c0-04edbd9e6415","extension":{"installed_extension_count":2},"extensions":{"alerts":{"initialized":true},"chrome_url_overrides":{},"last_chrome_version":"147.0.3912.98","pdf_upsell_triggered":false,"pinned_extension_migration":true,"pinned_extensions":[]},"fsd":{"retention_policy_last_version":147},"gaia_cookie":{"periodic_report_time_2":"13423001237298631"},"intl":{"selected_languages":"en-GB,en,en-US"},"language_dwell_time_average":{"en":35521.375,"it":3.0,"lb":9.0},"language_model_counters":{"en":15,"it":1,"lb":3},"language_usage_count":{"en":8,"it":1,"lb":1},"media":{"engagement":{"schema_version":5}},"migrated_user_scripts_toggle":true,"muid":{"last_sync":"13423001237298163","values_seen":[]},"optimization_guide":{"hintsfetcher":{"hosts_successfully_fetched":{}},"previously_registered_optimization_types":{"ABOUT_THIS_SITE":true,"AUTOFILL_ACTOR_IFRAME_ORIGIN_ALLOWLIST":true,"GLIC_ACTION_PAGE_BLOCK":true,"HISTORY_CLUSTERS":true,"LOADING_PREDICTOR":true,"MERCHANT_TRUST_SIGNALS_V2":true,"PAGE_ENTITIES":true,"PRICE_TRACKING":true,"SALIENT_IMAGE":true,"SAVED_TAB_GROUP":true,"V8_COMPILE_HINTS":true}},"password_manager":{"account_store_backup_password_cleaning_last_timestamp":"13422825350282160","account_store_migrated_to_os_crypt_async":true,"profile_store_backup_password_cleaning_last_timestamp":"13422825350282713","profile_store_migrated_to_os_crypt_async":true},"personalization_data_consent":{"personalization_in_context_consent_can_prompt":true,"personalization_in_context_count":0},"privacy_sandbox":{"first_party_sets_data_access_allowed_initialized":true},"profile":{"avatar_index":20,"background_password_check":{"check_fri_weight":9,"check_interval":"2592000000000","check_mon_weight":6,"check_sat_weight":6,"check_sun_weight":6,"check_thu_weight":9,"check_tue_weight":9,"check_wed_weight":9,"next_check_time":"13424909115774370"},"content_settings":{"exceptions":{"3pcd_heuristics_grants":{},"abusive_notification_permissions":{},"access_to_get_all_screens_media_in_session":{},"anti_abuse":{},"app_banner":{},"ar":{},"are_suspicious_notifications_allowlisted_by_user":{},"auto_picture_in_picture":{},"auto_select_certificate":{},"automatic_downloads":{},"automatic_fullscreen":{},"autoplay":{},"background_sync":{},"bluetooth_chooser_data":{},"bluetooth_guard":{},"bluetooth_scanning":{},"camera_pan_tilt_zoom":{},"captured_surface_control":{},"clear_browsing_data_cookies_exceptions":{},"client_hints":{},"clipboard":{},"controlled_frame":{},"cookie_controls_metadata":{"file:///*,*":{"last_modified":"13423062967160860","setting":{}},"https://[*.]eclipse.org,*":{"last_modified":"13423060788778495","setting":{}}},"cookies":{},"direct_sockets":{},"direct_sockets_private_network_access":{},"display_media_system_audio":{},"disruptive_notification_permissions":{},"durable_storage":{},"edge_ad_targeting":{},"edge_ad_targeting_data":{},"edge_all_file_read_access":{},"edge_browser_action":{},"edge_sdsm":{},"edge_split_screen":{},"edge_tech_scam_detection":{},"edge_u2f_api_request":{},"edge_user_agent_token":{},"fedcm_idp_registration":{},"fedcm_idp_signin":{},"fedcm_share":{},"file_system_access_chooser_data":{},"file_system_access_extended_permission":{},"file_system_access_restore_permission":{},"file_system_last_picked_directory":{},"file_system_read_guard":{},"file_system_write_guard":{},"formfill_metadata":{},"geolocation":{},"geolocation_with_options":{},"hand_tracking":{},"has_migrated_local_network_access":true,"hid_chooser_data":{},"hid_guard":{},"http_allowed":{},"https_enforced":{},"idle_detection":{},"images":{},"important_site_info":{},"initialized_translations":{},"intent_picker_auto_display":{},"javascript":{},"javascript_jit":{},"javascript_optimizer":{},"keyboard_lock":{},"legacy_cookie_access":{},"legacy_cookie_scope":{},"local_fonts":{},"local_network":{},"local_network_access":{},"loopback_network":{},"media_engagement":{"https://www.eclipse.org:443,*":{"expiration":"13430764207030926","last_modified":"13422988207030932","lifetime":"7776000000000","setting":{"hasHighScore":false,"lastMediaPlaybackTime":0.0,"mediaPlaybacks":0,"visits":5}}},"media_stream_camera":{},"media_stream_mic":{},"midi_sysex":{},"mixed_script":{},"nfc_devices":{},"notification_interactions":{},"notification_permission_review":{},"notifications":{},"ondevice_languages_downloaded":{},"password_protection":{},"payment_handler":{},"permission_actions_history":{},"permission_autoblocking_data":{},"permission_autorevocation_data":{},"pointer_lock":{},"popups":{},"protected_media_identifier":{},"protocol_handler":{},"reduced_accept_language":{},"safe_browsing_url_check_data":{},"secure_network":{},"secure_network_sites":{},"sensors":{},"serial_chooser_data":{},"serial_guard":{},"site_engagement":{"https://www.eclipse.org:443,*":{"last_modified":"13423060788781450","setting":{"lastEngagementTime":1.342306078878144e+16,"lastShortcutLaunchTime":0.0,"pointsAddedToday":4.5,"rawScore":19.99711684546938}}},"sleeping_tabs":{},"sound":{},"speaker_selection":{},"ssl_cert_decisions":{},"storage_access":{},"storage_access_header_origin_trial":{},"subresource_filter":{},"subresource_filter_data":{},"suspicious_notification_ids":{},"suspicious_notification_show_original":{},"top_level_storage_access":{},"trackers":{},"trackers_data":{},"tracking_org_exceptions":{},"tracking_org_relationships":{},"typosquatting":{},"unused_site_permissions":{},"usb_chooser_data":{},"usb_guard":{},"vr":{},"web_app_installation":{},"webid_api":{},"webid_auto_reauthn":{},"window_placement":{}},"pref_version":1},"created_by_version":"147.0.3912.98","creation_time":"13422825290227113","default_content_setting_values":{"has_migrated_local_network_access":true},"edge_password_is_using_new_login_db_path":false,"edge_password_login_db_path_flip_flop_count":0,"edge_profile_id":"a229742e-1a76-40e7-b7b9-b0cbc2f225f1","edge_user_with_non_zero_passwords":false,"exit_type":"Normal","has_seen_signin_fre":false,"is_relative_to_aad":false,"last_engagement_time":"13423060788781439","last_time_obsolete_http_credentials_removed":1778351750.282291,"last_time_password_store_metrics_reported":1778514754.564646,"managed_user_id":"","name":"Profile 1","network_pbs":{},"observed_session_time":{"feedback_rating_in_product_help_observed_session_time_key_147.0.3912.98":7.0},"password_hash_data_list":[],"signin_fre_seen_time":"13422825290260630","were_old_google_logins_removed":true},"reset_prepopulated_engines":false,"safety_hub":{"unused_site_permissions_revocation":{"migration_completed":true}},"saved_tab_groups":{"did_enable_shared_tab_groups_in_last_session":false,"specifics_to_data_migration":true},"sessions":{"event_log":[{"crashed":false,"time":"13422825290268704","type":0},{"did_schedule_command":false,"first_session_service":true,"tab_count":1,"time":"13422825356403533","type":2,"window_count":1},{"crashed":false,"time":"13422843140823994","type":0},{"did_schedule_command":false,"first_session_service":true,"tab_count":3,"time":"13422843168919448","type":2,"window_count":3},{"crashed":false,"time":"13422904239947130","type":0},{"did_schedule_command":false,"first_session_service":true,"tab_count":3,"time":"13422905046795006","type":2,"window_count":3},{"crashed":false,"time":"13422988324555180","type":0},{"did_schedule_command":false,"first_session_service":true,"tab_count":3,"time":"13422991310815867","type":2,"window_count":3},{"crashed":false,"time":"13423060788521975","type":0},{"did_schedule_command":false,"first_session_service":true,"tab_count":3,"time":"13423061419290311","type":2,"window_count":3}],"session_data_status":1},"signin":{"accounts_metadata_dict":{},"allowed":true},"spellcheck":{"dictionaries":["en-GB"]},"syncing_theme_prefs_migrated_to_non_syncing":true,"tab_search":{"pinned_to_tabstrip":false,"pinned_to_tabstrip_migration_complete":true},"total_passwords_available_for_account":0,"total_passwords_available_for_profile":0,"translate_site_blacklist":[],"translate_site_blocklist_with_time":{},"typosquatting":{"allowlist_migration_done":true},"user_experience_metrics":{"personalization_data_consent_enabled_last_known_value":false},"webrtc":{"udp_port_range":"0-0"}} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Secure Preferences b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Secure Preferences index 087bf40..b282223 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Secure Preferences +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Secure Preferences @@ -1 +1 @@ -{"extensions":{"settings":{"dgiklkfkllikcanfonkcabmbdfmgleag":{"account_extension_type":0,"active_permissions":{"api":[],"explicit_host":[],"manifest_permissions":[],"scriptable_host":[]},"commands":{},"content_settings":[],"creation_flags":1,"disable_reasons":[],"events":[],"first_install_time":"13422825290276856","from_webstore":false,"incognito_content_settings":[],"incognito_preferences":{},"last_update_time":"13422825290276856","location":5,"manifest":{"content_capabilities":{"include_globs":["https://*excel.officeapps.live.com/*","https://*onenote.officeapps.live.com/*","https://*powerpoint.officeapps.live.com/*","https://*word-edit.officeapps.live.com/*","https://*excel.officeapps.live.com.mcas.ms/*","https://*onenote.officeapps.live.com.mcas.ms/*","https://*word-edit.officeapps.live.com.mcas.ms/*","https://*excel.partner.officewebapps.cn/*","https://*onenote.partner.officewebapps.cn/*","https://*powerpoint.partner.officewebapps.cn/*","https://*word-edit.partner.officewebapps.cn/*","https://*excel.gov.online.office365.us/*","https://*onenote.gov.online.office365.us/*","https://*powerpoint.gov.online.office365.us/*","https://*word-edit.gov.online.office365.us/*","https://*excel.dod.online.office365.us/*","https://*onenote.dod.online.office365.us/*","https://*powerpoint.dod.online.office365.us/*","https://*word-edit.dod.online.office365.us/*","https://*visio.partner.officewebapps.cn/*","https://*visio.gov.online.office365.us/*","https://*visio.dod.online.office365.us/*"],"matches":["https://*.officeapps.live.com/*","https://*.officeapps.live.com.mcas.ms/*","https://*.partner.officewebapps.cn/*","https://*.gov.online.office365.us/*","https://*.dod.online.office365.us/*","https://*.app.whiteboard.microsoft.com/*","https://*.whiteboard.office.com/*","https://*.app.int.whiteboard.microsoft.com/*","https://*.whiteboard.office365.us/*","https://*.dev.whiteboard.microsoft.com/*"],"permissions":["clipboardRead","clipboardWrite"]},"default_locale":"en","description":"This extension grants Microsoft web sites permission to read and write from the clipboard.","key":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCz4t/X7GeuP6GBpjmxndrjtzF//4CWeHlC68rkoV7hP3h5Ka6eX7ZMNlYJkSjmB5iRmPHO5kR1y7rGY8JXnRPDQh/CQNLVA7OsKeV6w+UO+vx8KGI+TrTAhzH8YGcMIsxsUjxtC4cBmprja+xDr0zVp2EMgqHu+GBKgwSRHTkDuwIDAQAB","manifest_version":2,"minimum_chrome_version":"77","name":"Microsoft Clipboard Extension","version":"1.0"},"path":"C:\\Program Files (x86)\\Microsoft\\EdgeWebView\\Application\\147.0.3912.98\\resources\\edge_clipboard","preferences":{},"regular_only_preferences":{},"was_installed_by_default":false,"was_installed_by_oem":false},"mhjfbmdgcfjbbpaeojofohoefgiehjai":{"account_extension_type":0,"active_permissions":{"api":["contentSettings","fileSystem","fileSystem.write","metricsPrivate","tabs","resourcesPrivate","pdfViewerPrivate","fileSystem.readFullPath","errorReporting","edgeLearningToolsPrivate","fileSystem.getCurrentEntry","edgePdfPrivate","edgeCertVerifierPrivate"],"explicit_host":["edge://resources/*","edge://webui-test/*"],"manifest_permissions":[],"scriptable_host":[]},"commands":{},"content_settings":[],"creation_flags":1,"disable_reasons":[],"events":[],"first_install_time":"13422825290276320","from_webstore":false,"incognito_content_settings":[],"incognito_preferences":{},"last_update_time":"13422825290276320","location":5,"manifest":{"content_security_policy":"script-src 'self' 'wasm-eval' blob: filesystem: chrome://resources chrome://webui-test; object-src * blob: externalfile: file: filesystem: data:; trusted-types edge-internal fast-html pdf-url edge-pdf-static-policy;","description":"","incognito":"split","key":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDN6hM0rsDYGbzQPQfOygqlRtQgKUXMfnSjhIBL7LnReAVBEd7ZmKtyN2qmSasMl4HZpMhVe2rPWVVwBDl6iyNE/Kok6E6v6V3vCLGsOpQAuuNVye/3QxzIldzG/jQAdWZiyXReRVapOhZtLjGfywCvlWq7Sl/e3sbc0vWybSDI2QIDAQAB","manifest_version":2,"mime_types":["application/pdf"],"mime_types_handler":"edge_pdf/index.html","name":"Microsoft Edge PDF Viewer","offline_enabled":true,"permissions":["errorReporting","chrome://resources/","chrome://webui-test/","contentSettings","metricsPrivate","edgeCertVerifierPrivate","edgeLearningToolsPrivate","edgePdfPrivate","pdfViewerPrivate","resourcesPrivate","tabs",{"fileSystem":["write","readFullPath","getCurrentEntry"]}],"version":"1","web_accessible_resources":["pdf_embedder.css"]},"path":"C:\\Program Files (x86)\\Microsoft\\EdgeWebView\\Application\\147.0.3912.98\\resources\\edge_pdf","preferences":{},"regular_only_preferences":{},"was_installed_by_default":false,"was_installed_by_oem":false}}},"protection":{"macs":{"browser":{"show_home_button":"EF8E04BCF6F7C232231E69DAE481170653D82ED686DDBF2991FEFD946EB7522E","show_home_button_encrypted_hash":"djEwES0pBeA6lQPz4lNbUECw65WK0BMloADMhqKdbIa/fznAey0Kth2p+EaK0w0axHpT1rPQWjXtSIWwMnDd"},"default_search_provider_data":{"template_url_data":"FCFE985DC4470CDE6D77C27E055CB0622C9CC7AD6BC6B9E1847519F7B8DEE144","template_url_data_encrypted_hash":"djEwk7S2do81tv8/2L6h4wuBu5o+3bXC9QwSFWqgY8ZvxW3VlZk6bQSdj4stYDJuvNmG603nhlQBrz8+3XXR"},"edge":{"services":{"account_id":"CEF02DAD6F29EDA114575937C8F508621AE39F5C2738FAEDF89FCBB71E1C1BA3","account_id_encrypted_hash":"djEw2BOo4Kw3h6SJFCTtF0wwbvdgCwecr5lrbyHqTlUCCvoLFYf6+cesaU/wjwuSjr6tKBKYcYf/HW1ENfxj","last_username":"103B84FBAB0098687AD51A1C08493EFDAEB5F7EF6D86BBE2F39A61127527FBB7","last_username_encrypted_hash":"djEwKmCwiq8DXtbQFFTv/utTpP2GW1/+skfUThLjoikfLfFBm09xvIDwkygInruh6ATopBOkLxYbWWUiNDwf"}},"enterprise_signin":{"policy_recovery_token":"CD42B0D9C6B42377D8101DB574DD3166F3A9E94F1DB639394916929D5EF5DAC2","policy_recovery_token_encrypted_hash":"djEwNrdta60Rpxq10CEnFFeNfJ4R2AD+l08FSV/8ytPRhcvQ/t21kvZS+qENMRWWYBSEKlr60wqSuNHExTq+"},"extensions":{"install":{"initiallist":"3E78B078F98B045DFE906AB9531C92D6208035B4C12DBA309EFB5E15958EB4A5","initiallist_encrypted_hash":"djEwBeIvUIayxyzG3p8lnU9BbL4Pt/TrkTABdvc6frgnnW+bCnGGlZVVpvlW8Zwd8a0hjCHogn3wLlOyizRF","initialprovidername":"40E3B3529940888791F691E760B354D1975C4DE1C69D4F79D038D1E6E57213DF","initialprovidername_encrypted_hash":"djEw/RZ00y2uQPAXebeeNPsDwujFQLhfALCaJ2CzqAW4i8rymg/7qRLG09FxhrHmilW2jzcoWUFfgc6Wdl2M"},"settings":{"dgiklkfkllikcanfonkcabmbdfmgleag":"DA5FA348ACCFF784D34BB92F5675EE2FB160B53982751D3826CC007363E8284B","mhjfbmdgcfjbbpaeojofohoefgiehjai":"E5EC068D6C43F3F738FE1B38C3A7D681AD40CE86A10355B79FC06F895BAC9828"},"settings_encrypted_hash":{"dgiklkfkllikcanfonkcabmbdfmgleag":"djEwW/W9yUl95wR3OGLokJJFO8ZdrKccBm/uMXPM/U7lceKoZfJlKHCRfpUzZ5FDiAFsm1F9er0eUXOHd+zi","mhjfbmdgcfjbbpaeojofohoefgiehjai":"djEwnyvcsab2OJaIfppRjaBRM84Crj6e0RZtWqcCGW5W4ZPKNYoozij1UymuHY09paRQQikacNHSTx4jg5jU"},"ui":{"developer_mode":"2DBEBCCD41AA2009A8A787B8BD6D40749D4BAE6F5B4C817F2185B896E17E2F88","developer_mode_encrypted_hash":"djEwc7uGx7laHV7W1VeuE37LFm0BkWXFziluUFpLwYjlZ8G85nhu/97IJuOPM0ETB3TSnKCZruEBTDB0hkkk"}},"google":{"services":{"last_signed_in_username":"072FB2F17167EF75B4CFC99246F44C08AC2BBEF6A9E38CE03B2024A42C23FE84","last_signed_in_username_encrypted_hash":"djEwRlCeGX7jE9sPz2CVaSwjnPIfAyWRVM+Tz88xtVtDNXr2uYBtVWH9m0eOcuSNMeDMrb5HbPZ/2JhWXdfI"}},"homepage":"78069B504433DDA1B1E463C057E727B790FEF1FCC64CAB5672F563FF4BE366FF","homepage_encrypted_hash":"djEwrJlCKVFmpUuUVIESwO6doE6i65oaHdi9zv8KtqJx0U8+SuFQuNzz++EspSwwbvs9cmAwYiPdOJcPRWrJ","homepage_is_newtabpage":"F733D8383D60B3033BE28BA305EECEDE724D34C8FD94B30025F423B51393A590","homepage_is_newtabpage_encrypted_hash":"djEwJpUKpUaA0PwCbjzUz6Kq3rMtRB8wstyYgaiblVPMuSxRIfrR/GFrOOafP4ZJdKxPP2LTRIgnWY+LvX6F","media":{"cdm":{"origin_data":"D37EC83B68B1EF5650F106F4A24081A49B4DF9F5678E7EC6A85E161A98A08E4B","origin_data_encrypted_hash":"djEwdQ7rDoX63F/XSRYoVfMgil31wvOsgqJ/0y3L6ge0qUjgoEWFAV92tS7g2/XOOl4MlZzDbTLcfz+Ux3vQ"},"storage_id_salt":"B2E9290C6F6859BEB974309F06D9E137958B4AE07302B17AAE243C417F7EA569","storage_id_salt_encrypted_hash":"djEwWEHlCtv0RH9ELuLgmZKcSQHDo4seZyhpKGt0/mF4uhgBm8r4+FLS4cvv5d0X7vUWQ3ywFYnuRcELhJMT"},"pinned_tabs":"6EE16DC2F5850603ED8BDEA03AEFF18B572EE9FFFBC60EA1A9EED8FA68C0F5DB","pinned_tabs_encrypted_hash":"djEwaDpUbF6uLpBoOnz68xWzcRz2R5GJpdWpdukE7MrYcEc5qb2GFuPyoEP9f8bi3p2mahpwgLPQSTlFWmBz","prefs":{"preference_reset_time":"15C19F277D4917DCF71B31F461B2D0C8DBB3B848428CA9BC3C5C6BC48574AC87","preference_reset_time_encrypted_hash":"djEwpmSiY/R1FpD2G0hbLmraseN8FK4wvjsJU3xe9zs4f+8kBdQg3mTKnqBSGabW2k760oOpgX1pQ1yAU2zK"},"safebrowsing":{"incidents_sent":"939F8A46FD612B2F11302FE860AA28AC2BB97403B61A579D55FF125171603A19","incidents_sent_encrypted_hash":"djEwPqQs0EeeemuMxF4QRdgluDnXiPcp0FxKeHnKOR1AeMikaSGoDbYqZKCvxTwUfZLAJXqkERCUkgKpPqQd"},"schedule_to_flush_to_disk":"73B00FF74CAD3D8DEB71835592DE11F42B31D48B72EAE99CDAA89E3332F146A6","schedule_to_flush_to_disk_encrypted_hash":"djEw1ux3baFg33w4q7EWXfIciOVU+/CvwcpoFWjmdRuSS2fz/EScopHpR5uq4kgjdEX1uSgKGEKH6fpL3NV/","search_provider_overrides":"F89D61352813CEF1214763E778885A6264DB78F18556CF125DB7E7269A975DEA","search_provider_overrides_encrypted_hash":"djEwhBzRmXmBGPO436PJUkEkNvO7V9LxdpAplpzFSl3ziqR9GnqYZpusQ+kTCzuRlSIAemA7KfXHqqDurvnL","session":{"restore_on_startup":"01D0DC40F4692ABDB2D5ACF617641F9F792DFAF368CDC870D173736D7C3A2DF1","restore_on_startup_encrypted_hash":"djEwlpI6T8rgpeHmCYunwO957It/faD+czJuOkR8Xp0kIgSDm0YusWO+shh4tXZfAdOBNqpC9QpBi3DrMKzw","startup_urls":"D1197E0D92DA48044470C7DAA2988BB7F626A57B23FF417848ECDAC833189798","startup_urls_encrypted_hash":"djEwFgjmg0tb9dlPDyUaI2u1RpPI+RrAEs29mrGBVgy7YT5zy7JNGcQndcr+RRgEFYIYpuCAqDu+ZOCwtKwf"}},"super_mac":"D86A358CBF6AA8A4008064A52FE46A81B5E3DC5916B65D93F711AC090A4A22E6"},"schedule_to_flush_to_disk":"13422904239960103"} \ No newline at end of file +{"extensions":{"settings":{"dgiklkfkllikcanfonkcabmbdfmgleag":{"account_extension_type":0,"active_permissions":{"api":[],"explicit_host":[],"manifest_permissions":[],"scriptable_host":[]},"commands":{},"content_settings":[],"creation_flags":1,"disable_reasons":[],"events":[],"first_install_time":"13422825290276856","from_webstore":false,"incognito_content_settings":[],"incognito_preferences":{},"last_update_time":"13422825290276856","location":5,"manifest":{"content_capabilities":{"include_globs":["https://*excel.officeapps.live.com/*","https://*onenote.officeapps.live.com/*","https://*powerpoint.officeapps.live.com/*","https://*word-edit.officeapps.live.com/*","https://*excel.officeapps.live.com.mcas.ms/*","https://*onenote.officeapps.live.com.mcas.ms/*","https://*word-edit.officeapps.live.com.mcas.ms/*","https://*excel.partner.officewebapps.cn/*","https://*onenote.partner.officewebapps.cn/*","https://*powerpoint.partner.officewebapps.cn/*","https://*word-edit.partner.officewebapps.cn/*","https://*excel.gov.online.office365.us/*","https://*onenote.gov.online.office365.us/*","https://*powerpoint.gov.online.office365.us/*","https://*word-edit.gov.online.office365.us/*","https://*excel.dod.online.office365.us/*","https://*onenote.dod.online.office365.us/*","https://*powerpoint.dod.online.office365.us/*","https://*word-edit.dod.online.office365.us/*","https://*visio.partner.officewebapps.cn/*","https://*visio.gov.online.office365.us/*","https://*visio.dod.online.office365.us/*"],"matches":["https://*.officeapps.live.com/*","https://*.officeapps.live.com.mcas.ms/*","https://*.partner.officewebapps.cn/*","https://*.gov.online.office365.us/*","https://*.dod.online.office365.us/*","https://*.app.whiteboard.microsoft.com/*","https://*.whiteboard.office.com/*","https://*.app.int.whiteboard.microsoft.com/*","https://*.whiteboard.office365.us/*","https://*.dev.whiteboard.microsoft.com/*"],"permissions":["clipboardRead","clipboardWrite"]},"default_locale":"en","description":"This extension grants Microsoft web sites permission to read and write from the clipboard.","key":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCz4t/X7GeuP6GBpjmxndrjtzF//4CWeHlC68rkoV7hP3h5Ka6eX7ZMNlYJkSjmB5iRmPHO5kR1y7rGY8JXnRPDQh/CQNLVA7OsKeV6w+UO+vx8KGI+TrTAhzH8YGcMIsxsUjxtC4cBmprja+xDr0zVp2EMgqHu+GBKgwSRHTkDuwIDAQAB","manifest_version":2,"minimum_chrome_version":"77","name":"Microsoft Clipboard Extension","version":"1.0"},"path":"C:\\Program Files (x86)\\Microsoft\\EdgeWebView\\Application\\147.0.3912.98\\resources\\edge_clipboard","preferences":{},"regular_only_preferences":{},"was_installed_by_default":false,"was_installed_by_oem":false},"mhjfbmdgcfjbbpaeojofohoefgiehjai":{"account_extension_type":0,"active_permissions":{"api":["contentSettings","fileSystem","fileSystem.write","metricsPrivate","tabs","resourcesPrivate","pdfViewerPrivate","fileSystem.readFullPath","errorReporting","edgeLearningToolsPrivate","fileSystem.getCurrentEntry","edgePdfPrivate","edgeCertVerifierPrivate"],"explicit_host":["edge://resources/*","edge://webui-test/*"],"manifest_permissions":[],"scriptable_host":[]},"commands":{},"content_settings":[],"creation_flags":1,"disable_reasons":[],"events":[],"first_install_time":"13422825290276320","from_webstore":false,"incognito_content_settings":[],"incognito_preferences":{},"last_update_time":"13422825290276320","location":5,"manifest":{"content_security_policy":"script-src 'self' 'wasm-eval' blob: filesystem: chrome://resources chrome://webui-test; object-src * blob: externalfile: file: filesystem: data:; trusted-types edge-internal fast-html pdf-url edge-pdf-static-policy;","description":"","incognito":"split","key":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDN6hM0rsDYGbzQPQfOygqlRtQgKUXMfnSjhIBL7LnReAVBEd7ZmKtyN2qmSasMl4HZpMhVe2rPWVVwBDl6iyNE/Kok6E6v6V3vCLGsOpQAuuNVye/3QxzIldzG/jQAdWZiyXReRVapOhZtLjGfywCvlWq7Sl/e3sbc0vWybSDI2QIDAQAB","manifest_version":2,"mime_types":["application/pdf"],"mime_types_handler":"edge_pdf/index.html","name":"Microsoft Edge PDF Viewer","offline_enabled":true,"permissions":["errorReporting","chrome://resources/","chrome://webui-test/","contentSettings","metricsPrivate","edgeCertVerifierPrivate","edgeLearningToolsPrivate","edgePdfPrivate","pdfViewerPrivate","resourcesPrivate","tabs",{"fileSystem":["write","readFullPath","getCurrentEntry"]}],"version":"1","web_accessible_resources":["pdf_embedder.css"]},"path":"C:\\Program Files (x86)\\Microsoft\\EdgeWebView\\Application\\147.0.3912.98\\resources\\edge_pdf","preferences":{},"regular_only_preferences":{},"was_installed_by_default":false,"was_installed_by_oem":false}}},"protection":{"macs":{"browser":{"show_home_button":"EF8E04BCF6F7C232231E69DAE481170653D82ED686DDBF2991FEFD946EB7522E","show_home_button_encrypted_hash":"djEwL8uhOweF+aSXdVnZZCIhI8ut2MIkV2Ifpow2m7C2KwdD2ImnynsMTUtIDKhbvz1gCXzobc1aikKknU2/"},"default_search_provider_data":{"template_url_data":"FCFE985DC4470CDE6D77C27E055CB0622C9CC7AD6BC6B9E1847519F7B8DEE144","template_url_data_encrypted_hash":"djEwsV6dwtNgxRBH7WD97rlioqEQpWS+Qb4MPc/xoDu+1CwYiM5mZml96+bpyqR1DawoFdft0oBmUunVeY01"},"edge":{"services":{"account_id":"CEF02DAD6F29EDA114575937C8F508621AE39F5C2738FAEDF89FCBB71E1C1BA3","account_id_encrypted_hash":"djEw491EWyrxenfn24WE1y4KwOvA/PbiBsNUmsVwF3ULTN/aDtABfpvV5ydqY3wCcl5V/RGc6FFgFRw8iPu9","last_username":"103B84FBAB0098687AD51A1C08493EFDAEB5F7EF6D86BBE2F39A61127527FBB7","last_username_encrypted_hash":"djEwoFZD1uazNPuZc7ATnQJ4mcM6Mh4MUzGT1wcYX9fLATiXtVJ7gXje84cwjbeedOUQxCN9bD2124MlcC7T"}},"enterprise_signin":{"policy_recovery_token":"CD42B0D9C6B42377D8101DB574DD3166F3A9E94F1DB639394916929D5EF5DAC2","policy_recovery_token_encrypted_hash":"djEwoP/kAE/q8okeDU1JkvqZ8fGhS1dgD8LWDcSMOsjB5WB3KTBe1LoJKX61Hf2mvq1TrZ+Q8ROqsviGtLMB"},"extensions":{"install":{"initiallist":"3E78B078F98B045DFE906AB9531C92D6208035B4C12DBA309EFB5E15958EB4A5","initiallist_encrypted_hash":"djEwCWUW2GW8n23hc8mioZWTV120jZOL4lQEkh3Rmv9Y28f++ZKlEKz4WJ46V6wt47NNrk3QYWPXHHA8pKGx","initialprovidername":"40E3B3529940888791F691E760B354D1975C4DE1C69D4F79D038D1E6E57213DF","initialprovidername_encrypted_hash":"djEwHxPdef316nVa3pkGmgecHzDkjZdUPrQot/HVwl22WgUkrd9TQUhnN63kTcBYPuHsQ34sP13X1MLYoLAP"},"settings":{"dgiklkfkllikcanfonkcabmbdfmgleag":"DA5FA348ACCFF784D34BB92F5675EE2FB160B53982751D3826CC007363E8284B","mhjfbmdgcfjbbpaeojofohoefgiehjai":"E5EC068D6C43F3F738FE1B38C3A7D681AD40CE86A10355B79FC06F895BAC9828"},"settings_encrypted_hash":{"dgiklkfkllikcanfonkcabmbdfmgleag":"djEwGtEEOyYxcp6tbvtqVVAKH8gD3XeX1/vIDHWLKUIt1CnGY2jQoFECn11hymTJmEm3G6XcsS2lyhqqt45i","mhjfbmdgcfjbbpaeojofohoefgiehjai":"djEwmtrNQXU3uHfY/EFbcDJLxIIgLyZnGJka+pcyoVFBzK2fkdLHsykP4IblNF63Kfc5ChS7aWZhD8QcbB+E"},"ui":{"developer_mode":"2DBEBCCD41AA2009A8A787B8BD6D40749D4BAE6F5B4C817F2185B896E17E2F88","developer_mode_encrypted_hash":"djEwzVUgVB8GMd6G9uXs3Go9LZxkWrdYvZNPw45bAmfFyLR5Kr1fdO8NHYr5EW+UxHS8kDKayJ4u51lbq6rx"}},"google":{"services":{"last_signed_in_username":"072FB2F17167EF75B4CFC99246F44C08AC2BBEF6A9E38CE03B2024A42C23FE84","last_signed_in_username_encrypted_hash":"djEwX9b5Tuz21PIuysyAmDs5x/L0V6XoWLxJaeuN2tNw+GQcjIEIsHTyyxv0Zs/eion3RXeVV9S3XcqfSP+T"}},"homepage":"78069B504433DDA1B1E463C057E727B790FEF1FCC64CAB5672F563FF4BE366FF","homepage_encrypted_hash":"djEwJDPrl1w78AmwYbt3hE3CW/INl+GjItryUiBCbpHfDYPk9AWXWtkb0Gl/Uc1d2U3WDPTx1Ae4wpYZG6YV","homepage_is_newtabpage":"F733D8383D60B3033BE28BA305EECEDE724D34C8FD94B30025F423B51393A590","homepage_is_newtabpage_encrypted_hash":"djEwHmDRsT56AL3edBMCwOfphMJ1v7m5hnLS9QiP8AB32Wat2KAJvcWI4h+BIA2M4kEknr2nSFekREuUqU07","media":{"cdm":{"origin_data":"D37EC83B68B1EF5650F106F4A24081A49B4DF9F5678E7EC6A85E161A98A08E4B","origin_data_encrypted_hash":"djEwYZWrwlLwvlhAiNrQ7K6jPhWi/7WdubojgREORnjFpfhQaFL2juMW9GFwzaYcbbhIHFWHmrYPNRAqHZZK"},"storage_id_salt":"B2E9290C6F6859BEB974309F06D9E137958B4AE07302B17AAE243C417F7EA569","storage_id_salt_encrypted_hash":"djEwZ55iar03s+XzH3G91HJKglyeGleoKT9DSy0uwY6ikkXvIK86bIqzf87iVVFNG98n6wGpDL5/XyPnHPxR"},"pinned_tabs":"6EE16DC2F5850603ED8BDEA03AEFF18B572EE9FFFBC60EA1A9EED8FA68C0F5DB","pinned_tabs_encrypted_hash":"djEw7UfQ/v1wQMoP1ClGHj3Ex2whN8C4AxozwCqx3VqoW69XWocRIN6j/pu8M/KA7StF17xfQ3OYD0n1zxMH","prefs":{"preference_reset_time":"15C19F277D4917DCF71B31F461B2D0C8DBB3B848428CA9BC3C5C6BC48574AC87","preference_reset_time_encrypted_hash":"djEw+7Xg6l4If4IeoFR77qNTeYBQQ5/l8AKddBQkPfW96QnlTETum3TXkW6Pey9zrScFGq/3nLko2pe/abHN"},"safebrowsing":{"incidents_sent":"939F8A46FD612B2F11302FE860AA28AC2BB97403B61A579D55FF125171603A19","incidents_sent_encrypted_hash":"djEw0YOjYAZ1mUmZos4/1JGb6VB67e5FTS4KUWeiQ2mqDPFcUhO6Rh+umEspotOWC/Knx8+ZNZV0T69v9ul6"},"schedule_to_flush_to_disk":"B921C47CB1B9AF2645B0B218E94D712899746A4B87F5FEC16D80E7E8628354BE","schedule_to_flush_to_disk_encrypted_hash":"djEwM3JXC8dVo8cKHTyC61IA99E3dfDxIZneCdOye9TbL7F8Ot3F07Kp0LI8Er4PdCCIIgAoDYR/eQYhkhCV","search_provider_overrides":"F89D61352813CEF1214763E778885A6264DB78F18556CF125DB7E7269A975DEA","search_provider_overrides_encrypted_hash":"djEwsXUkHR0+aa8lbZIqA8RvL5ZOKtzr41sTJOUOAWrarpejnIlpZhI2NBr1R1+YnC/oANMO1mDN1MQ9TX/H","session":{"restore_on_startup":"01D0DC40F4692ABDB2D5ACF617641F9F792DFAF368CDC870D173736D7C3A2DF1","restore_on_startup_encrypted_hash":"djEwEX9YKErXMtFZYIH5nm8z2QAkEzFYbMr+uoGJn0j65vAiSnfwjVQ1oSxC8pBlx06cYOm+DB3WVRrhv+rR","startup_urls":"D1197E0D92DA48044470C7DAA2988BB7F626A57B23FF417848ECDAC833189798","startup_urls_encrypted_hash":"djEwXe94kk+fUDOyfOu/Mj61ZpzCnt8C6voLEGgM5x8XiPBbg/aEvLiJ+PorLY5MqnpgYLU12FFyjGZd9Tqw"}},"super_mac":"1D3E585592FFD00D2A9D892B60E0AA5572BFC09E57F76B4084F2CAF6EAC2EECA"},"schedule_to_flush_to_disk":"13423060788537557"} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/000003.log b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/000003.log index de23708..82a7b60 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/000003.log and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/000003.log differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/LOG b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/LOG index a70c1ba..e69de29 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/LOG +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/LOG @@ -1,3 +0,0 @@ -2026/05/10-18:30:40.323 292c Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Session Storage/MANIFEST-000001 -2026/05/10-18:30:40.324 292c Recovering log #3 -2026/05/10-18:30:40.325 292c Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Session Storage/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/LOG.old b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/LOG.old index 149d0de..7eddd10 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/LOG.old +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Session Storage/LOG.old @@ -1,3 +1,3 @@ -2026/05/10-01:32:21.088 744 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Session Storage/MANIFEST-000001 -2026/05/10-01:32:21.089 744 Recovering log #3 -2026/05/10-01:32:21.090 744 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Session Storage/000003.log +2026/05/11-17:52:05.695 22c0 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Session Storage/MANIFEST-000001 +2026/05/11-17:52:05.698 22c0 Recovering log #3 +2026/05/11-17:52:05.700 22c0 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Session Storage/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Site Characteristics Database/000003.log b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Site Characteristics Database/000003.log index b02e28d..c4c4024 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Site Characteristics Database/000003.log and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Site Characteristics Database/000003.log differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Site Characteristics Database/LOG.old b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Site Characteristics Database/LOG.old index 3bd0c2e..8db5fdc 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Site Characteristics Database/LOG.old +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Site Characteristics Database/LOG.old @@ -1,3 +1,3 @@ -2026/05/10-01:32:20.822 1518 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Site Characteristics Database/MANIFEST-000001 -2026/05/10-01:32:20.823 1518 Recovering log #3 -2026/05/10-01:32:20.823 1518 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Site Characteristics Database/000003.log +2026/05/11-17:52:04.553 14e8 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Site Characteristics Database/MANIFEST-000001 +2026/05/11-17:52:04.555 14e8 Recovering log #3 +2026/05/11-17:52:04.556 14e8 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Site Characteristics Database/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Sync Data/LevelDB/LOG.old b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Sync Data/LevelDB/LOG.old index 8aa050a..8fc2794 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Sync Data/LevelDB/LOG.old +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Sync Data/LevelDB/LOG.old @@ -1,3 +1,3 @@ -2026/05/10-01:32:20.822 1df8 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Sync Data\LevelDB/MANIFEST-000001 -2026/05/10-01:32:20.823 1df8 Recovering log #3 -2026/05/10-01:32:20.823 1df8 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Sync Data\LevelDB/000003.log +2026/05/11-17:52:04.556 4154 Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Sync Data\LevelDB/MANIFEST-000001 +2026/05/11-17:52:04.557 4154 Recovering log #3 +2026/05/11-17:52:04.557 4154 Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\Sync Data\LevelDB/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Top Sites b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Top Sites index be2a99c..040f082 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Top Sites and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/Top Sites differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/favorites_diagnostic.log b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/favorites_diagnostic.log index 892cbf7..a90710c 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/favorites_diagnostic.log +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/favorites_diagnostic.log @@ -1,3 +1,5 @@ 2026-05-09 18:34:50.289: [INFO] OnDoneLoading sync enabled: 0 2026-05-09 23:32:20.836: [INFO] OnDoneLoading sync enabled: 0 2026-05-10 16:30:39.960: [INFO] OnDoneLoading sync enabled: 0 +2026-05-11 15:52:04.577: [INFO] OnDoneLoading sync enabled: 0 +2026-05-12 11:59:48.537: [INFO] OnDoneLoading sync enabled: 0 diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/000003.log b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/000003.log index f2ce9e0..1dec713 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/000003.log and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/000003.log differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/LOG.old b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/LOG.old index 4657c83..f697957 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/LOG.old +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/LOG.old @@ -1,3 +1,3 @@ -2026/05/10-01:32:20.839 8ac Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\shared_proto_db/MANIFEST-000001 -2026/05/10-01:32:20.839 8ac Recovering log #3 -2026/05/10-01:32:20.840 8ac Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\shared_proto_db/000003.log +2026/05/11-17:52:04.599 96c Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\shared_proto_db/MANIFEST-000001 +2026/05/11-17:52:04.600 96c Recovering log #3 +2026/05/11-17:52:04.601 96c Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\shared_proto_db/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/metadata/000003.log b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/metadata/000003.log index a3e99b8..f3092f3 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/metadata/000003.log and b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/metadata/000003.log differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/metadata/LOG.old b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/metadata/LOG.old index 6f974e6..93293f5 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/metadata/LOG.old +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Default/shared_proto_db/metadata/LOG.old @@ -1,3 +1,3 @@ -2026/05/10-01:32:20.838 8ac Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\shared_proto_db\metadata/MANIFEST-000001 -2026/05/10-01:32:20.838 8ac Recovering log #3 -2026/05/10-01:32:20.838 8ac Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\shared_proto_db\metadata/000003.log +2026/05/11-17:52:04.580 96c Reusing MANIFEST C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\shared_proto_db\metadata/MANIFEST-000001 +2026/05/11-17:52:04.581 96c Recovering log #3 +2026/05/11-17:52:04.581 96c Reusing old log C:\Users\eslusarz\Documents\eclipse-workspace\.metadata\.plugins\org.eclipse.swt\EBWebView\Default\shared_proto_db\metadata/000003.log diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_0 b/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_0 index fe0d1e6..756bb7a 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_0 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_0 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_1 b/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_1 index 6ee3712..a456fd6 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_1 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_1 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_3 b/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_3 index aa796d3..3be4a74 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_3 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/GrShaderCache/data_3 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/GraphiteDawnCache/data_1 b/.metadata/.plugins/org.eclipse.swt/EBWebView/GraphiteDawnCache/data_1 index 20fd5d4..4e559bb 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/GraphiteDawnCache/data_1 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/GraphiteDawnCache/data_1 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Local State b/.metadata/.plugins/org.eclipse.swt/EBWebView/Local State index 9f55b3b..164e4e4 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Local State +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Local State @@ -1 +1 @@ -{"accessibility":{"captions":{"common_models_path":"","soda_translation_binary_path":""}},"autofill":{"ablation_seed":"FivBD7Ft8QE="},"breadcrumbs":{"enabled":true,"enabled_time":"13422825290225753"},"default_browser":{"browser_name_enum":6},"desktop_session_duration_tracker":{"last_session_end_timestamp":"1778491645"},"domain_actions_config":"H4sIAAAAAAAAAL1abW8bNxL+K4ZwH5LCWitJm975EASFkUMKNGiQS9ED6p4wS452JyI5NMnV7rrJfz9QL7Y2Wq2XcnAfLEujeWbI4exwXvTXREg95xU6RxInl39NwFpFAgKx8ZPLP7YElHPLikQ7uZz8alT7prHs8b2C9gOCbCfnE8kayEwuJ2Wlqkywnnw5TwfrypPIIgpPlhFWWctVqPLTRXhFptig/zyfrFGEG3MY0HhUQGht/DKS3JoUlR8gfieJKzJ4D7ijRHUrdJ7YTC6ffTmfCJYoEg/oLUl8t3iLK3EV0V/Z5gHjDoANmYBG8qBhDvHbPe4Te7apo2XmZBQZTHVIG36twv5KwdqscKA1ONUOeMEB0Jfg0DKZcBpqKhcpQMNxW5nnsQBFqyGvPuDnxYLECYgXL384GZRpAT7TfjTYoHSn7ctgGIsQiiuZaRKOPS9Gw9YGT1ATELS/V3Oi71WjjSdYazbR39kVY0E15lldQvARl7BCwZYUJ20KJA/G4UOAExnQ6BWBWUHSFsCKKmkHogQHIqBLWVYJobBpahRUElN0cIkuybQS0QKlOEpEqFQVHnGZaUyGpKghSNsIKlyhUZD7jEYHWw1uKdi2CYeiMSS5o67cIkV8a8h8ggSE+btJ2DGHND+36KzChkKKjSwnea116NGETQKQosaR1ymmuqlIqTwtvN3UaBJUONS8wiwf7beuMjW0OukZ9JXhhDX51oQSPUGCnwRsgmAXsElZWO0oulcCouWhUuKA/RYspSnY3WgnXdiBloGT4lZ+V1aM4y+Yi8FK6ABRWT9ct2wQPQl4zO3DfEEqoJuzmfNiMfc1BVGOy8KvNhL+tRbQCVpd2x5ZWBd+sD4UNrEqeK+AzEdswm8ffvGx+OoUqWAKroLPHrLwoJR4zT9OglcgBjxoELsAgTkPOeAgvMb18k8FU0PmRPDNzcla86GIM4xlJ+NV4k/Eh5rCYPQaREvygp0cfAL6BGxr5zdX7yNhzRG2HIfPCEmV+IxsOxgOF9SgfPPuTSd1wLBQNGDvMWgfKkk8YPRBIdt2kIZbjs6WfbLfQEi1fLyQR29GHsmPx0vAIzXieAkL91gJZB4t4UhlnXAY8A2OM8tPscVemzAZyxYNScHGoAixIIfbymGNuaeAftNyOBIo+uTuOo87ou7pJZKGAucaCkOLdu6wwCYxXiiu0XfaI5GQfde/f8yhJV106rAN6RhCOKDCK/LdJO2OegwX9G0nVuvbo5zgCuxmcWvKMf4897H06PRBd7RjGEsmOOzugTJLJu78qLdEhwiQK+wWDJ5u0WUctiqPwoFcbvKvfFyAKAdSE40GnOwcqJAm25DF4GW184QVqCp+vr5+HVf66omWnxv19GzzqWnUfgv83iF2MD9VT66v5XdPz/xUPXs5m+2zd7xhh5i/mM2aF7PZ9XV2Nn/2fDZr/jGbZfuwjTPc8Wu5Zm1Ul2nnBzu+//7t7HVN8lUUuc+45wA71n9qaN4iFWV4tVl8JPxOMpTbz2f7Ava8YSfg4vmLl83F2cWP8d8+774P7JifaJRU6c8qrvhz4zUo9fTirKwK7GDvHOBOy2vS8/rVj89nZ9u3z77/vrO3+/O/U/Zuo+zfUcvnX6LKpxdn/1m/uTiMKOsae46NVexi1fDItv1zLU1Ks5V0MfVT7c00hnBYgga6RZkioifqji/lptjYY0Hg8cVfXdeZAPIep2jBFQaP3th9ha1Eiym9H+EQAp5WCUtcoJHoHNxyUv0t0VNh0J2olk0BTpq0ml9WYhn/Ck5BPVxt9WAc4jS+CFRq6llRAErr2W6ry9FOtuH3rZHbhy9FGRU8rdHlCC7QEtV4tRHJ+ScM3lZ5Esw6XlCaJutYcwLC+ABxGphiCkVmiZLMeDWpozkN9qbC4zlNTy93W5CNBpw6/QNrfZY8arRoHJCK/UpIGkdxFXIHD6RHfc3nBtVAZdnT6kRwoswMrNIixhbXQslJMePEafKSV5QUZ6J/x+tofSdFbaM9xAd2UGDyYfuVSJjw+rY4ni33dZdFGeealYmDhf9Ta/bB/s63G6O2oHVyH/yB37P0JADrfmqmMO2es+BCvFBTcb5km+XP81OAtWPWyUCFBYi2RFChTAk3OSiFIXhRVgqnjE7RMt6T5ehzJwXGL9sUpRoKElMVi4aH+vM/m/16nrx+s82vP7YWN9/v5fB3qgYQvR3/yqObQxGb/ml5+1XpWONvP3XSDsf1thM+OZ9YCOVcw3p08MfkQoBDdFPpEDS6i5I1Xkz+7DVcn2xPquQKQ8BpfOKOekgfVrdZ3d7i8OThHre1IcoCP/ISzQe0CgRqNPvl26Eta8zn8bc8i63lUkcVjrU9yP0dSklDDfpeVECFhQNbkpE0MIs+RAfS6Hmxwa1f15QUEbbyJZoi3iipy46qDNcG6ySN6yKJK8vGgaFUZF2yQs8a22ogO+zHgl8qIJVk4ojzoDXnNDgy6gWiqGBFPklhdZt5WwVDy7VhXZWi0MiwSl6kIm3BCYKBmXU/1PIKHBpeJi4TfQAJPNjGPUSyaiwsyQcwGfssiNGPSfwtSeoxsEpc3trDGvI5mKEB3wFOV6ECtaiMzEBSaCEnp0CApZB+IiMmjL24ERVXP1Cj92iKoeToZyNYkymuQKnusfT88O7YpG2nfBvv7ebz3q36lZYtH22pcxHJe+wbgT8Z2Y/byJ+DkfOvRHQvki//A5h5bsOPLQAA","edge":{"manageability":{"edge_last_active_time":"13422965242399717"},"mitigation_manager":{"renderer_app_container_compatible_count":1},"retrigger_features":[],"tab_stabs":{"closed_without_unfreeze_never_unfrozen":0,"closed_without_unfreeze_previously_unfrozen":0,"discard_without_unfreeze_never_unfrozen":0,"discard_without_unfreeze_previously_unfrozen":0},"tab_stats":{"frozen_daily":0,"unfrozen_daily":0}},"edge_ci":{"num_healthy_browsers_since_failure":3},"hardware_acceleration_mode_previous":true,"identity_combined_status":{"aad":1,"ad":1},"legacy":{"profile":{"name":{"migrated":true}}},"local":{"password_hash_data_list":[]},"network_time":{"network_time_mapping":{"local":1.778505320058342e+12,"network":1.778505325e+12,"ticks":77277954672.0,"uncertainty":1712561.0}},"optimization_guide":{"model_execution":{"last_usage_by_feature":{}},"model_store_metadata":{},"on_device":{"last_version":"147.0.3912.98","model_crash_count":0}},"os_crypt":{"audit_enabled":true,"encrypted_key":"RFBBUEkBAAAA0Iyd3wEV0RGMegDAT8KX6wEAAACiPxEnG1/CSY1jnLc4XUkbEAAAAB4AAABNAGkAYwByAG8AcwBvAGYAdAAgAEUAZABnAGUAAAAQZgAAAAEAACAAAAA5m+RU369qlDRNJw536rgYo0g7lbaG+8+1UYQKgVe5UwAAAAAOgAAAAAIAACAAAACdbioUEYXU0KmGVxkd+xO2PXzKDPnf35QIuaeuTDcNSjAAAAANUwQ1tAvl+bBa1dzjsYMVbdkI+ZGjD+J775LQjaGPbvJrVu+gH3jebbxz/FxLsl9AAAAAASWIjwzqxz0hwJWQhbROUd+FJv0v6KT2yDPhU5+s5kl2GMzbnJrtQFGQVlo7h8M6D6TLD0LO4nAWEO1sQzurdQ=="},"performance_intervention":{"last_daily_sample":"13422913239998106"},"phoenix":{"user_laf_toggle_state_static":2},"policy":{"last_statistics_update":"13422911690226895"},"profile":{"info_cache":{"Default":{"active_time":1778491640.805231,"avatar_icon":"chrome://theme/IDR_PROFILE_AVATAR_20","background_apps":false,"edge_account_cid":"","edge_account_environment":0,"edge_account_environment_string":"","edge_account_first_name":"","edge_account_last_name":"","edge_account_oid":"","edge_account_sovereignty":0,"edge_account_tenant_id":"","edge_account_type":0,"edge_create_profile_shortcut":false,"edge_non_signin_profile_type":1,"edge_profile_can_be_deleted":true,"edge_profile_can_be_edited":true,"edge_test_on_premises":false,"edge_wam_aad_for_app_account_type":0,"enterprise_label":"","force_signin_profile_locked":false,"gaia_given_name":"","gaia_id":"","gaia_name":"","hosted_domain":"","is_consented_primary_account":false,"is_ephemeral":false,"is_glic_eligible":false,"is_managed":0,"is_using_default_avatar":true,"is_using_default_name":true,"managed_user_id":"","metrics_bucket_index":1,"name":"Profile 1","signin.with_credential_provider":false,"user_name":""}},"last_active_profiles":["Default"],"metrics":{"next_bucket_index":2},"profile_counts_reported":"13422911690225981","profiles_order":["Default"]},"profile_network_context_service":{"http_cache_finch_experiment_groups":"None None None None"},"profiles":{"edge":{"guided_switch_pref":[],"multiple_profiles_with_same_account":false},"edge_sso_info":{"msa_first_profile_key":"Default","msa_sso_algo_state":1},"signin_last_seen_version":"147.0.3912.98","signin_last_updated_time":1778438139.955908},"sentinel_creation_time":"0","session_id_generator_last_value":"339850313","signin":{"active_accounts_last_emitted":"13422911690194951"},"startup_boost":{"last_browser_open_time":"13422987292739334"},"subresource_filter":{"ruleset_version":{"checksum":860988201,"content":"10.34.0.84","format":37}},"tab_stats":{"discards_expired":0,"discards_external":0,"discards_proactive":0,"discards_urgent":0,"last_daily_sample":"13422913239945839","max_tabs_per_window":1,"reloads_expired":0,"reloads_external":0,"reloads_urgent":0,"total_tab_count_max":10,"window_count_max":10},"telemetry_client":{"cloned_install":{"user_data_dir_id":11297294},"governance":{"last_dma_change_date":"13422825290206518","last_known_cps":0},"host_telclient_path":"QzpcUHJvZ3JhbSBGaWxlcyAoeDg2KVxNaWNyb3NvZnRcRWRnZVdlYlZpZXdcQXBwbGljYXRpb25cMTQ3LjAuMzkxMi45OFx0ZWxjbGllbnQuZGxs","sample_id":28518521},"uninstall_metrics":{"installation_date2":"1778351690"},"updateclientdata":{"apps":{"alpjnmnfbgfkmmpcfpejmmoebdndedno":{"cohort":"rrf@0.74","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"46.0.0.0"},"eeobbhfgfagbclfofmgbdfoicabjdbkn":{"cohort":"rrf@0.29","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"1.0.0.10"},"fgbafbciocncjfbbonhocjaohoknlaco":{"cohort":"rrf@0.48","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"2026.3.23.1"},"jbfaflocpnkhbgcijpkiafdpbjkedane":{"cohort":"rrf@0.05","cohortname":"","installdate":-1},"kpfehajjjbbcifeehjgfgnabifknmdad":{"cohort":"rrf@0.76","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"120.0.6050.0"},"laoigpblnllgcgjnjnllmfolckpjlhki":{"cohort":"rrf@0.96","cohortname":"","installdate":-1},"ndikpojcjlepofdkaaldkinkjbeeebkl":{"cohort":"rrf@0.35","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"10.34.0.84"},"oankkpibpaokgecfckkdkgaoafllipag":{"cohort":"rrf@0.68","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"6498.2025.9.4"},"ohckeflnhegojcjlcpbfpciadgikcohk":{"cohort":"rrf@0.36","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"0.0.1.7"},"ojblfafjmiikbkepnnolpgbbhejhlcim":{"cohort":"rrf@0.85","cohortname":"","installdate":-1}}},"updateclientlastupdatecheckerror":-105,"updateclientlastupdatecheckerrorcategory":5,"updateclientlastupdatecheckerrorextracode1":0,"user_experience_metrics":{"chrome_download_action_count":0,"client_id2":"{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}C:\\Users\\eslusarz0s:05D2D359-2B14-4013-B5BA-6ED5F41F2761","diagnostics":{"last_data_collection_level_on_launch":1},"limited_entropy_randomization_source":"94FB2CB93E02CD91F8FEEE6A7854498F","low_entropy_source3":4436,"machine_id":492731,"payload_counter":1,"pseudo_low_entropy_source":452,"reporting_enabled":false,"reset_client_id_deterministic":true,"session_id":2,"stability":{"browser_last_live_timestamp":"13422986728606217","exited_cleanly":true,"stats_buildtime":"1777534620","stats_version":"147.0.3912.98-64","system_crash_count":0}},"variations_compressed_seed":"safe_seed_content","variations_config_ids":"P-R-1736541-5-5,P-R-1315481-1-8,P-R-1541171-6-9,P-R-1528200-3-4,P-R-1113531-4-9,P-R-68474-9-12,P-R-61206-24-23,P-R-60617-8-21,P-R-45373-10-87,P-R-1075865-4-8","variations_crash_streak":0,"variations_failed_to_fetch_seed_streak":1,"variations_google_groups":{"Default":[]},"variations_last_fetch_time":"13422975320478873","variations_last_runtime_fetch_time":"13422978920358685","variations_runtime_compressed_seed":"H4sIAAAAAAAAAG2Py07DMBBF/2W2ZFQ/Jo4diQ1pIGFVqq6gLEJjTBF1mpdEqPLvqLW66/Lcc6U7c4Ks8Z97Vy57SGGFa+TMSEExchQUhUArRshRJhdOtGQKOXIdUCpxwWCV5CpGQqEuGEtBEgUGSYwZifIqpU6IUKMJVnJtDAqDZEy0wiVyHmvFCQVeL5E6UQwFcgYR5LWz69EP+4MNT0B6gvxwHKabxvrq48c+2moYO9tD+gbWdjt4n+cIClvVtuvPtawZ/dBNWVNbSKHcnIc2lYMUtvASP7PClbtGqwffHkXjstxNrL/7Jfpqiz/vn8R3vXhdtO5+CzDP/+zFLFRfAQAA","variations_runtime_config_ids":"P-R-1093245-1-24,P-R-108604-1-37,P-R-78306-1-18,P-R-73626-1-17,P-R-63165-4-26,P-R-53243-2-7,P-R-40093-3-26,P-R-38744-8-97,P-R-31899-29-499,P-D-1158614-2-4,P-R-1038760-2-10","variations_safe_compressed_seed":"H4sIAAAAAAAAAJVVbXPiNhD+Kxl9tlLL79DpB8JLjh7c0QCXdnqZjLDXjiayRCUZwmT47x1ZhIT0mFz5wHh3n93n2dVafkbD/hx1n1GfMxCmL0XJqkZRw6RYrgtqYLgBYSxiANzQiayGgq44FKhbUq7BQ6OG8zmY85GRgn8aEPkOdYnv7z00fMp5U8DwyYASlDvScaHHYiIr1DWqAQ8570RWC6oqMKiLoKjgXhvLgWyVogIHatUxbQMTmVP+BcxWqsdenoPW/QfIHy2icIgRUNMo0Kj7NzqD1uhu76HtJphTUazk05nssZacGjiAoBiXitbgkg9yRozDfKcN1G/Kc6bNmZLv8QOmIDdS7cYG3KFccekquL4slxv77begVxTMYiifKWnTPzPOoVgAhxqM2llSEO85a30Lq28Mth/nW7Z5kT84xnPl7MFYVAv/YznuW+Ca2uEYUBb0jAStAXVR/kCFAI48tKG8sZ4R2nvHMKxl/vAmGPru9xajwCgqdM1Muxn3UtxvmYJ7w2qQjbmvGedMQy5Fod+UCmwVK/DrBpRiBSw/T/W5jpaP9bXc2GUVOUzs8d15ZzpqwS81W+gr55TlSmpZmssRU9rMqDK7w/bd2FdEmxvQDTce8Uj866m89jU8K9BFe5zL7UfyWuiHAm9hdaXkVoO6nClp5KopL5efp5duOWdKloyD51udP5FkqNGXE1nNDVXG873o/yT1Zb3mYKDNc0M5buRMrufUhtt/JqpzAxpJlcMx7Yj2UK3tFQPaLAUrpaoHTBvFVo19Dz4xbWSlaH1+npWSzTo6yngzS3K6pi0w/glgASVtuLm2+LPwu/3hAmwX6aYRrxfhsF6b3Y9D/x0MQKly1FabQ1WDMO0lY8EjJYVhoHpNwUDklvqLFFbJtDfucY66qL3mkYdub4enDp2vy8Z6/Pa5aqgqXowNqPZxGiZxXyo4zexLYUCYOagNy0G/44HVn4tT1xUT1anHtn7qOe7aUlvug3/voU9Ai/Y8n9FwQSvURd8R/PJ1MMtnoXnQo3U4Hq9JXk5mtfx9ES2X5SYjV+VqOdwkf12Pf/uOLN/TmrXTRHNqvAu/czGlu4vAD5IL0umGUTeOL66ni7a3Rhi168vCDnNsXXbJG33wtFfSy4dvPHC67NcZzfANJmlM4sTHBBOvtf0siNPWto4BjoIwy3CAE3T6bTxkh0kcERzj2GWHJI4yggnOnB1HhKQEJ7hzsIMs8H0c4sjZhIRxSHB0iCdZlEa4g0ngTBL4CQ4iHITO9hOS4gwHTmsUh2mIiY+zFP14b51IP42zJMYRztD7hTx0QZKUtJWI73RFaeiT5LUPEnc6WYzJS5+EhB0S4yB2Y7IknSwMI0xw4qQmfpphgsOjlR6zEz/LAkywazIK/SzA4SEWBWlkqwRov/8X5nU8zUYJAAA=","variations_safe_seed_date":"13422900277000000","variations_safe_seed_fetch_time":"13422975320478873","variations_safe_seed_locale":"en-GB","variations_safe_seed_milestone":147,"variations_safe_seed_signature":"","variations_seed_client_version_at_store":"147.0.3912.98","variations_seed_date":"13422975325000000","variations_seed_etag":"\"e/ODPcP3thsFp3IIp1cfLPmoJT4UUfv81BfbUEv6YGI=\"","variations_seed_milestone":147,"variations_seed_runtime_etag":"\"Q5J0HgIco86Bnqp2ogCEgy0s+x44hqHznnG2jd/Z/qg=\"","variations_seed_runtime_serial_number":"\"Q5J0HgIco86Bnqp2ogCEgy0s+x44hqHznnG2jd/Z/qg=\"","variations_seed_serial_number":"\"e/ODPcP3thsFp3IIp1cfLPmoJT4UUfv81BfbUEv6YGI=\"","variations_seed_signature":"","was":{"restarted":false}} \ No newline at end of file +{"accessibility":{"captions":{"common_models_path":"","soda_translation_binary_path":""}},"autofill":{"ablation_seed":"FivBD7Ft8QE="},"breadcrumbs":{"enabled":true,"enabled_time":"13422825290225753"},"default_browser":{"browser_name_enum":6},"desktop_session_duration_tracker":{"last_session_end_timestamp":"1778491645"},"domain_actions_config":"H4sIAAAAAAAAAL1abW8bNxL+K4ZwH5LCWitJm975EASFkUMKNGiQS9ED6p4wS452JyI5NMnV7rrJfz9QL7Y2Wq2XcnAfLEujeWbI4exwXvTXREg95xU6RxInl39NwFpFAgKx8ZPLP7YElHPLikQ7uZz8alT7prHs8b2C9gOCbCfnE8kayEwuJ2Wlqkywnnw5TwfrypPIIgpPlhFWWctVqPLTRXhFptig/zyfrFGEG3MY0HhUQGht/DKS3JoUlR8gfieJKzJ4D7ijRHUrdJ7YTC6ffTmfCJYoEg/oLUl8t3iLK3EV0V/Z5gHjDoANmYBG8qBhDvHbPe4Te7apo2XmZBQZTHVIG36twv5KwdqscKA1ONUOeMEB0Jfg0DKZcBpqKhcpQMNxW5nnsQBFqyGvPuDnxYLECYgXL384GZRpAT7TfjTYoHSn7ctgGIsQiiuZaRKOPS9Gw9YGT1ATELS/V3Oi71WjjSdYazbR39kVY0E15lldQvARl7BCwZYUJ20KJA/G4UOAExnQ6BWBWUHSFsCKKmkHogQHIqBLWVYJobBpahRUElN0cIkuybQS0QKlOEpEqFQVHnGZaUyGpKghSNsIKlyhUZD7jEYHWw1uKdi2CYeiMSS5o67cIkV8a8h8ggSE+btJ2DGHND+36KzChkKKjSwnea116NGETQKQosaR1ymmuqlIqTwtvN3UaBJUONS8wiwf7beuMjW0OukZ9JXhhDX51oQSPUGCnwRsgmAXsElZWO0oulcCouWhUuKA/RYspSnY3WgnXdiBloGT4lZ+V1aM4y+Yi8FK6ABRWT9ct2wQPQl4zO3DfEEqoJuzmfNiMfc1BVGOy8KvNhL+tRbQCVpd2x5ZWBd+sD4UNrEqeK+AzEdswm8ffvGx+OoUqWAKroLPHrLwoJR4zT9OglcgBjxoELsAgTkPOeAgvMb18k8FU0PmRPDNzcla86GIM4xlJ+NV4k/Eh5rCYPQaREvygp0cfAL6BGxr5zdX7yNhzRG2HIfPCEmV+IxsOxgOF9SgfPPuTSd1wLBQNGDvMWgfKkk8YPRBIdt2kIZbjs6WfbLfQEi1fLyQR29GHsmPx0vAIzXieAkL91gJZB4t4UhlnXAY8A2OM8tPscVemzAZyxYNScHGoAixIIfbymGNuaeAftNyOBIo+uTuOo87ou7pJZKGAucaCkOLdu6wwCYxXiiu0XfaI5GQfde/f8yhJV106rAN6RhCOKDCK/LdJO2OegwX9G0nVuvbo5zgCuxmcWvKMf4897H06PRBd7RjGEsmOOzugTJLJu78qLdEhwiQK+wWDJ5u0WUctiqPwoFcbvKvfFyAKAdSE40GnOwcqJAm25DF4GW184QVqCp+vr5+HVf66omWnxv19GzzqWnUfgv83iF2MD9VT66v5XdPz/xUPXs5m+2zd7xhh5i/mM2aF7PZ9XV2Nn/2fDZr/jGbZfuwjTPc8Wu5Zm1Ul2nnBzu+//7t7HVN8lUUuc+45wA71n9qaN4iFWV4tVl8JPxOMpTbz2f7Ava8YSfg4vmLl83F2cWP8d8+774P7JifaJRU6c8qrvhz4zUo9fTirKwK7GDvHOBOy2vS8/rVj89nZ9u3z77/vrO3+/O/U/Zuo+zfUcvnX6LKpxdn/1m/uTiMKOsae46NVexi1fDItv1zLU1Ks5V0MfVT7c00hnBYgga6RZkioifqji/lptjYY0Hg8cVfXdeZAPIep2jBFQaP3th9ha1Eiym9H+EQAp5WCUtcoJHoHNxyUv0t0VNh0J2olk0BTpq0ml9WYhn/Ck5BPVxt9WAc4jS+CFRq6llRAErr2W6ry9FOtuH3rZHbhy9FGRU8rdHlCC7QEtV4tRHJ+ScM3lZ5Esw6XlCaJutYcwLC+ABxGphiCkVmiZLMeDWpozkN9qbC4zlNTy93W5CNBpw6/QNrfZY8arRoHJCK/UpIGkdxFXIHD6RHfc3nBtVAZdnT6kRwoswMrNIixhbXQslJMePEafKSV5QUZ6J/x+tofSdFbaM9xAd2UGDyYfuVSJjw+rY4ni33dZdFGeealYmDhf9Ta/bB/s63G6O2oHVyH/yB37P0JADrfmqmMO2es+BCvFBTcb5km+XP81OAtWPWyUCFBYi2RFChTAk3OSiFIXhRVgqnjE7RMt6T5ehzJwXGL9sUpRoKElMVi4aH+vM/m/16nrx+s82vP7YWN9/v5fB3qgYQvR3/yqObQxGb/ml5+1XpWONvP3XSDsf1thM+OZ9YCOVcw3p08MfkQoBDdFPpEDS6i5I1Xkz+7DVcn2xPquQKQ8BpfOKOekgfVrdZ3d7i8OThHre1IcoCP/ISzQe0CgRqNPvl26Eta8zn8bc8i63lUkcVjrU9yP0dSklDDfpeVECFhQNbkpE0MIs+RAfS6Hmxwa1f15QUEbbyJZoi3iipy46qDNcG6ySN6yKJK8vGgaFUZF2yQs8a22ogO+zHgl8qIJVk4ojzoDXnNDgy6gWiqGBFPklhdZt5WwVDy7VhXZWi0MiwSl6kIm3BCYKBmXU/1PIKHBpeJi4TfQAJPNjGPUSyaiwsyQcwGfssiNGPSfwtSeoxsEpc3trDGvI5mKEB3wFOV6ECtaiMzEBSaCEnp0CApZB+IiMmjL24ERVXP1Cj92iKoeToZyNYkymuQKnusfT88O7YpG2nfBvv7ebz3q36lZYtH22pcxHJe+wbgT8Z2Y/byJ+DkfOvRHQvki//A5h5bsOPLQAA","edge":{"manageability":{"edge_last_active_time":"13422965242399717"},"mitigation_manager":{"renderer_app_container_compatible_count":2},"retrigger_features":[],"tab_stabs":{"closed_without_unfreeze_never_unfrozen":0,"closed_without_unfreeze_previously_unfrozen":0,"discard_without_unfreeze_never_unfrozen":0,"discard_without_unfreeze_previously_unfrozen":0},"tab_stats":{"frozen_daily":0,"unfrozen_daily":0}},"edge_ci":{"num_healthy_browsers_since_failure":5},"hardware_acceleration_mode_previous":true,"identity_combined_status":{"aad":1,"ad":1},"legacy":{"profile":{"name":{"migrated":true}}},"local":{"password_hash_data_list":[]},"network_time":{"network_time_mapping":{"local":1.778587190216709e+12,"network":1.778587194e+12,"ticks":40445706866.0,"uncertainty":1537319.0}},"optimization_guide":{"model_execution":{"last_usage_by_feature":{}},"model_store_metadata":{},"on_device":{"last_version":"147.0.3912.98","model_crash_count":0}},"os_crypt":{"audit_enabled":true,"encrypted_key":"RFBBUEkBAAAA0Iyd3wEV0RGMegDAT8KX6wEAAACiPxEnG1/CSY1jnLc4XUkbEAAAAB4AAABNAGkAYwByAG8AcwBvAGYAdAAgAEUAZABnAGUAAAAQZgAAAAEAACAAAAA5m+RU369qlDRNJw536rgYo0g7lbaG+8+1UYQKgVe5UwAAAAAOgAAAAAIAACAAAACdbioUEYXU0KmGVxkd+xO2PXzKDPnf35QIuaeuTDcNSjAAAAANUwQ1tAvl+bBa1dzjsYMVbdkI+ZGjD+J775LQjaGPbvJrVu+gH3jebbxz/FxLsl9AAAAAASWIjwzqxz0hwJWQhbROUd+FJv0v6KT2yDPhU5+s5kl2GMzbnJrtQFGQVlo7h8M6D6TLD0LO4nAWEO1sQzurdQ=="},"performance_intervention":{"last_daily_sample":"13423001237299175"},"phoenix":{"user_laf_toggle_state_static":2},"policy":{"last_statistics_update":"13423001237299252"},"profile":{"info_cache":{"Default":{"active_time":1778491640.805231,"avatar_icon":"chrome://theme/IDR_PROFILE_AVATAR_20","background_apps":false,"edge_account_cid":"","edge_account_environment":0,"edge_account_environment_string":"","edge_account_first_name":"","edge_account_last_name":"","edge_account_oid":"","edge_account_sovereignty":0,"edge_account_tenant_id":"","edge_account_type":0,"edge_create_profile_shortcut":false,"edge_non_signin_profile_type":1,"edge_profile_can_be_deleted":true,"edge_profile_can_be_edited":true,"edge_test_on_premises":false,"edge_wam_aad_for_app_account_type":0,"enterprise_label":"","force_signin_profile_locked":false,"gaia_given_name":"","gaia_id":"","gaia_name":"","hosted_domain":"","is_consented_primary_account":false,"is_ephemeral":false,"is_glic_eligible":false,"is_managed":0,"is_using_default_avatar":true,"is_using_default_name":true,"managed_user_id":"","metrics_bucket_index":1,"name":"Profile 1","signin.with_credential_provider":false,"user_name":""}},"last_active_profiles":["Default"],"metrics":{"next_bucket_index":2},"profile_counts_reported":"13423001237298717","profiles_order":["Default"]},"profile_network_context_service":{"http_cache_finch_experiment_groups":"None None None None"},"profiles":{"edge":{"guided_switch_pref":[],"multiple_profiles_with_same_account":false},"edge_sso_info":{"msa_first_profile_key":"Default","msa_sso_algo_state":1},"signin_last_seen_version":"147.0.3912.98","signin_last_updated_time":1778527637.299286},"sentinel_creation_time":"0","session_id_generator_last_value":"339850461","signin":{"active_accounts_last_emitted":"13423001237298827"},"startup_boost":{"last_browser_open_time":"13423062980146491"},"subresource_filter":{"ruleset_version":{"checksum":860988201,"content":"10.34.0.84","format":37}},"tab_stats":{"discards_expired":0,"discards_external":0,"discards_proactive":0,"discards_urgent":0,"last_daily_sample":"13423001237299042","max_tabs_per_window":1,"reloads_expired":0,"reloads_external":0,"reloads_urgent":0,"total_tab_count_max":4,"window_count_max":4},"telemetry_client":{"cloned_install":{"user_data_dir_id":11297294},"governance":{"last_dma_change_date":"13422825290206518","last_known_cps":0},"host_telclient_path":"QzpcUHJvZ3JhbSBGaWxlcyAoeDg2KVxNaWNyb3NvZnRcRWRnZVdlYlZpZXdcQXBwbGljYXRpb25cMTQ3LjAuMzkxMi45OFx0ZWxjbGllbnQuZGxs","sample_id":28518521},"uninstall_metrics":{"installation_date2":"1778351690"},"updateclientdata":{"apps":{"alpjnmnfbgfkmmpcfpejmmoebdndedno":{"cohort":"","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"46.0.0.0"},"eeobbhfgfagbclfofmgbdfoicabjdbkn":{"cohort":"","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"1.0.0.10"},"fgbafbciocncjfbbonhocjaohoknlaco":{"cohort":"","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"2026.3.23.1"},"jbfaflocpnkhbgcijpkiafdpbjkedane":{"cohort":"","cohortname":"","installdate":-1},"kpfehajjjbbcifeehjgfgnabifknmdad":{"cohort":"","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"120.0.6050.0"},"laoigpblnllgcgjnjnllmfolckpjlhki":{"cohort":"","cohortname":"","installdate":-1},"ndikpojcjlepofdkaaldkinkjbeeebkl":{"cohort":"","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"10.34.0.84"},"oankkpibpaokgecfckkdkgaoafllipag":{"cohort":"","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"6498.2025.9.4"},"ohckeflnhegojcjlcpbfpciadgikcohk":{"cohort":"","cohortname":"","fp":"","installdate":-1,"max_pv":"0.0.0.0","pv":"0.0.1.7"},"ojblfafjmiikbkepnnolpgbbhejhlcim":{"cohort":"","cohortname":"","installdate":-1}}},"updateclientlastupdatecheckerror":0,"updateclientlastupdatecheckerrorcategory":0,"updateclientlastupdatecheckerrorextracode1":0,"user_experience_metrics":{"chrome_download_action_count":0,"client_id2":"{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}C:\\Users\\eslusarz0s:05D2D359-2B14-4013-B5BA-6ED5F41F2761","diagnostics":{"last_data_collection_level_on_launch":1},"limited_entropy_randomization_source":"94FB2CB93E02CD91F8FEEE6A7854498F","low_entropy_source3":4436,"machine_id":492731,"payload_counter":1,"pseudo_low_entropy_source":452,"reporting_enabled":false,"reset_client_id_deterministic":true,"session_id":4,"stability":{"browser_last_live_timestamp":"13423062588504930","exited_cleanly":true,"stats_buildtime":"1777534620","stats_version":"147.0.3912.98-64","system_crash_count":0}},"variations_compressed_seed":"safe_seed_content","variations_config_ids":"P-R-1736541-5-5,P-R-1315481-1-8,P-R-1541171-6-9,P-R-1528200-3-4,P-R-1113531-4-9,P-R-68474-9-12,P-R-61206-24-23,P-R-60617-8-21,P-R-45373-10-87,P-R-1075865-4-8","variations_crash_streak":0,"variations_failed_to_fetch_seed_streak":1,"variations_google_groups":{"Default":[]},"variations_last_fetch_time":"13423060788989366","variations_last_runtime_fetch_time":"13423060790429457","variations_runtime_compressed_seed":"H4sIAAAAAAAAAG2Py07DMBBF/2W2ZFQ/Jo4diQ1pIGFVqq6gLEJjTBF1mpdEqPLvqLW66/Lcc6U7c4Ks8Z97Vy57SGGFa+TMSEExchQUhUArRshRJhdOtGQKOXIdUCpxwWCV5CpGQqEuGEtBEgUGSYwZifIqpU6IUKMJVnJtDAqDZEy0wiVyHmvFCQVeL5E6UQwFcgYR5LWz69EP+4MNT0B6gvxwHKabxvrq48c+2moYO9tD+gbWdjt4n+cIClvVtuvPtawZ/dBNWVNbSKHcnIc2lYMUtvASP7PClbtGqwffHkXjstxNrL/7Jfpqiz/vn8R3vXhdtO5+CzDP/+zFLFRfAQAA","variations_runtime_config_ids":"P-R-1093245-1-24,P-R-108604-1-37,P-R-78306-1-18,P-R-73626-1-17,P-R-63165-4-26,P-R-53243-2-7,P-R-40093-3-26,P-R-38744-8-97,P-R-31899-29-499,P-D-1158614-2-4,P-R-1038760-2-10","variations_safe_compressed_seed":"H4sIAAAAAAAAAJVVbXPiNhD+Kxl9tlLL79DpB8JLjh7c0QCXdnqZjLDXjiayRCUZwmT47x1ZhIT0mFz5wHh3n93n2dVafkbD/hx1n1GfMxCmL0XJqkZRw6RYrgtqYLgBYSxiANzQiayGgq44FKhbUq7BQ6OG8zmY85GRgn8aEPkOdYnv7z00fMp5U8DwyYASlDvScaHHYiIr1DWqAQ8570RWC6oqMKiLoKjgXhvLgWyVogIHatUxbQMTmVP+BcxWqsdenoPW/QfIHy2icIgRUNMo0Kj7NzqD1uhu76HtJphTUazk05nssZacGjiAoBiXitbgkg9yRozDfKcN1G/Kc6bNmZLv8QOmIDdS7cYG3KFccekquL4slxv77begVxTMYiifKWnTPzPOoVgAhxqM2llSEO85a30Lq28Mth/nW7Z5kT84xnPl7MFYVAv/YznuW+Ca2uEYUBb0jAStAXVR/kCFAI48tKG8sZ4R2nvHMKxl/vAmGPru9xajwCgqdM1Muxn3UtxvmYJ7w2qQjbmvGedMQy5Fod+UCmwVK/DrBpRiBSw/T/W5jpaP9bXc2GUVOUzs8d15ZzpqwS81W+gr55TlSmpZmssRU9rMqDK7w/bd2FdEmxvQDTce8Uj866m89jU8K9BFe5zL7UfyWuiHAm9hdaXkVoO6nClp5KopL5efp5duOWdKloyD51udP5FkqNGXE1nNDVXG873o/yT1Zb3mYKDNc0M5buRMrufUhtt/JqpzAxpJlcMx7Yj2UK3tFQPaLAUrpaoHTBvFVo19Dz4xbWSlaH1+npWSzTo6yngzS3K6pi0w/glgASVtuLm2+LPwu/3hAmwX6aYRrxfhsF6b3Y9D/x0MQKly1FabQ1WDMO0lY8EjJYVhoHpNwUDklvqLFFbJtDfucY66qL3mkYdub4enDp2vy8Z6/Pa5aqgqXowNqPZxGiZxXyo4zexLYUCYOagNy0G/44HVn4tT1xUT1anHtn7qOe7aUlvug3/voU9Ai/Y8n9FwQSvURd8R/PJ1MMtnoXnQo3U4Hq9JXk5mtfx9ES2X5SYjV+VqOdwkf12Pf/uOLN/TmrXTRHNqvAu/czGlu4vAD5IL0umGUTeOL66ni7a3Rhi168vCDnNsXXbJG33wtFfSy4dvPHC67NcZzfANJmlM4sTHBBOvtf0siNPWto4BjoIwy3CAE3T6bTxkh0kcERzj2GWHJI4yggnOnB1HhKQEJ7hzsIMs8H0c4sjZhIRxSHB0iCdZlEa4g0ngTBL4CQ4iHITO9hOS4gwHTmsUh2mIiY+zFP14b51IP42zJMYRztD7hTx0QZKUtJWI73RFaeiT5LUPEnc6WYzJS5+EhB0S4yB2Y7IknSwMI0xw4qQmfpphgsOjlR6zEz/LAkywazIK/SzA4SEWBWlkqwRov/8X5nU8zUYJAAA=","variations_safe_seed_date":"13422975325000000","variations_safe_seed_fetch_time":"13423060788989366","variations_safe_seed_locale":"en-GB","variations_safe_seed_milestone":147,"variations_safe_seed_signature":"","variations_seed_client_version_at_store":"147.0.3912.98","variations_seed_date":"13423060793000000","variations_seed_etag":"\"e/ODPcP3thsFp3IIp1cfLPmoJT4UUfv81BfbUEv6YGI=\"","variations_seed_milestone":147,"variations_seed_runtime_etag":"\"Q5J0HgIco86Bnqp2ogCEgy0s+x44hqHznnG2jd/Z/qg=\"","variations_seed_runtime_serial_number":"\"Q5J0HgIco86Bnqp2ogCEgy0s+x44hqHznnG2jd/Z/qg=\"","variations_seed_serial_number":"\"e/ODPcP3thsFp3IIp1cfLPmoJT4UUfv81BfbUEv6YGI=\"","variations_seed_signature":"","was":{"restarted":false}} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/ShaderCache/data_1 b/.metadata/.plugins/org.eclipse.swt/EBWebView/ShaderCache/data_1 index 59f2c79..31b5c12 100644 Binary files a/.metadata/.plugins/org.eclipse.swt/EBWebView/ShaderCache/data_1 and b/.metadata/.plugins/org.eclipse.swt/EBWebView/ShaderCache/data_1 differ diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/SmartScreen/local/uriCache_ b/.metadata/.plugins/org.eclipse.swt/EBWebView/SmartScreen/local/uriCache_ index 3cfdb1c..06c4bd3 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/SmartScreen/local/uriCache_ +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/SmartScreen/local/uriCache_ @@ -1 +1 @@ -{"version":1,"cache_data":[{"file_hash":"145d0023f037c9bf","server_context":"1;f94c025f-7523-6972-b613-ce2c246c55ce;unkn:100;0.01","result":1,"response_category":"Allowed","expiration_time":1778470341295392},{"file_hash":"f4df362a8544bc8c","server_context":"1;f94c025f-7523-6972-b613-ce2c246c55ce;unkn:100;0.01","result":1,"response_category":"Allowed","expiration_time":1778470341295392}]} \ No newline at end of file +{"version":1,"cache_data":[{"file_hash":"145d0023f037c9bf","server_context":"1;f94c025f-7523-6972-b613-ce2c246c55ce;unkn:100;0.01","result":1,"response_category":"Allowed","expiration_time":1778615525476298},{"file_hash":"f4df362a8544bc8c","server_context":"1;f94c025f-7523-6972-b613-ce2c246c55ce;unkn:100;0.01","result":1,"response_category":"Allowed","expiration_time":1778615525474682}]} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.swt/EBWebView/Variations b/.metadata/.plugins/org.eclipse.swt/EBWebView/Variations index a157215..5d75f57 100644 --- a/.metadata/.plugins/org.eclipse.swt/EBWebView/Variations +++ b/.metadata/.plugins/org.eclipse.swt/EBWebView/Variations @@ -1 +1 @@ -{"user_experience_metrics.stability.exited_cleanly":false,"variations_crash_streak":0} \ No newline at end of file +{"user_experience_metrics.stability.exited_cleanly":false,"variations_crash_streak":1} \ No newline at end of file diff --git a/.metadata/version.ini b/.metadata/version.ini index b80b2b8..8872af9 100644 --- a/.metadata/version.ini +++ b/.metadata/version.ini @@ -1,3 +1,3 @@ -#Sun May 10 18:29:39 CEST 2026 +#Tue May 12 13:59:16 CEST 2026 org.eclipse.core.runtime=2 org.eclipse.platform=4.39.0.v20260226-0420 diff --git a/asdl/bin/list/mylinkedlist/MyLinkedList$MyLinkedListIterator.class b/asdl/bin/list/mylinkedlist/MyLinkedList$MyLinkedListIterator.class new file mode 100644 index 0000000..1eb3b0f Binary files /dev/null and b/asdl/bin/list/mylinkedlist/MyLinkedList$MyLinkedListIterator.class differ diff --git a/asdl/bin/list/mylinkedlist/MyLinkedList$Node.class b/asdl/bin/list/mylinkedlist/MyLinkedList$Node.class index c7eb928..f831781 100644 Binary files a/asdl/bin/list/mylinkedlist/MyLinkedList$Node.class and b/asdl/bin/list/mylinkedlist/MyLinkedList$Node.class differ diff --git a/asdl/bin/list/mylinkedlist/MyLinkedList.class b/asdl/bin/list/mylinkedlist/MyLinkedList.class index 388912d..1fb99ad 100644 Binary files a/asdl/bin/list/mylinkedlist/MyLinkedList.class and b/asdl/bin/list/mylinkedlist/MyLinkedList.class differ diff --git a/asdl/src/list/mylinkedlist/MyLinkedList.java b/asdl/src/list/mylinkedlist/MyLinkedList.java index 3137bcb..57049f5 100644 --- a/asdl/src/list/mylinkedlist/MyLinkedList.java +++ b/asdl/src/list/mylinkedlist/MyLinkedList.java @@ -1,6 +1,9 @@ package list.mylinkedlist; +import java.util.Collection; +import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import java.util.NoSuchElementException; public class MyLinkedList implements List { @@ -178,6 +181,325 @@ public class MyLinkedList implements List { return oldData; } + public String toString() { + StringBuffer result = new StringBuffer(); + for (Object x : this) result.append(x + " "); + return result.toString(); + } + + public boolean remove(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) { + + // Caso in cui esso sia un primo nodo + if (currentNode == head) { + removeFirst(); + return true; + } + + // Caso in cui esso sia un ultimo nodo + if (currentNode == tail) { + removeLast(); + return true; + } + + // Caso in cui sia in mezzo + Node prevNode = currentNode.prev; + Node nextNode = currentNode.next; + + prevNode.next = nextNode; + nextNode.prev = prevNode; + currentNode.prev = null; + currentNode.next = null; + + size--; + + return true; + } + currentNode = currentNode.next; + } + return false; + } + + public boolean contains(Object object) { + if (object == null || head == null) return false; + Node currentNode = head; + while (currentNode != null) { + if (currentNode.data.equals(object)) return true; + currentNode = currentNode.next; + } + return false; + } + + public Object[] toArray() { + if (head == null) return null; + Object[] array = new Object[size]; + Node currentNode = head; + int i = 0; + while (currentNode != null) { + array[i++] = currentNode; + currentNode = currentNode.next; + } + return array; + } + + public boolean equals(Object object) { + return object == this; + } + + // Parte iteratori + + public Iterator iterator() { + return new MyLinkedListIterator(); + } + + public ListIterator listIterator() { + return new MyLinkedListIterator(); + } + + private class MyLinkedListIterator implements ListIterator { + + // Variabili adoperate + private Node nextNode; + private Node prevNode; + private Node lastReturned = null; + private int posNext; + + public MyLinkedListIterator() { + nextNode = head; + prevNode = null; + posNext = 0; + } + + public MyLinkedListIterator(int index) { + if ((index < 0) || (index > size)) throw new IndexOutOfBoundsException(); + // Caso in cui sia il primo + if (index == 0) { + nextNode = head; + prevNode = null; + posNext = 0; + return; + } + // Caso in cui sia l'ultimo + if (index == size) { + nextNode = null; + prevNode = tail; + posNext = size; + return; + } + nextNode = head; + prevNode = null; + posNext = 0; + while (posNext < index) { + nextNode = nextNode.next; + prevNode = nextNode.prev; + posNext++; + } + } + + @Override + public boolean hasNext() { + return nextNode != null; + } + + @Override + public boolean hasPrevious() { + return prevNode != null; + } + + @Override + public E next() { + if (!hasNext()) throw new NoSuchElementException(); + E data = nextNode.data; + lastReturned = nextNode; + prevNode = nextNode; + nextNode = nextNode.next; + posNext++; + return data; + } + + @Override + public E previous() { + if (!hasPrevious()) throw new NoSuchElementException(); + E data = prevNode.data; + lastReturned = prevNode; + nextNode = prevNode; + prevNode = prevNode.prev; + posNext--; + return data; + } + + @Override + public int nextIndex() { + return posNext; + } + + @Override + public int previousIndex() { + return posNext - 1; + } + + /* + * Il metodo remove si occupa della rimozione del nodo appena restituito + */ + @Override + public void remove() { + // Se non è stato restituito alcun nodo + if (lastReturned == null) throw new NoSuchElementException(); + // Se l'ultimo elemento ad essere stato restituito è la testa + if (lastReturned == head) { + removeFirst(); + nextNode = head; // Head dopo la rimozione del primo nodo è il successivo a quello appena rimosso + prevNode = null; + posNext = 0; + lastReturned = null; + return; + } + // Se l'ultimo elemento ad essere stato restituito è la coda + if (lastReturned == tail) { + removeLast(); + nextNode = null; + prevNode = tail; + posNext = size; + lastReturned = null; + return; + } + // Se è un elemento generico + Node removingNode = lastReturned; + Node nNode = removingNode.next; + Node pNode = removingNode.prev; + + pNode.next = nNode; + nNode.prev = pNode; + removingNode.prev = null; + removingNode.next = null; + + if (lastReturned == prevNode) posNext--; + + nextNode = nNode; + prevNode = pNode; + size--; + lastReturned = null; + } + + /* + * Quando viene richiamata la add, l'elemento viene aggiunto a sinistra del cursore. + * Esempio di seguito: + * A | B + * chiamata add(X) + * A X | B + * Come detto prima la X viene aggiunta a sinistra + */ + @Override + public void add(E data) { + if (data == null) throw new NullPointerException(); + Node newNode = new Node(data, null, null); + // Se la lista è vuota + if (size == 0) { + tail = head = newNode; + prevNode = newNode; + size++; + posNext = 1; + return; + } + // Se il cursore è prima dell'HEAD + if (prevNode == null) { + addFirst(data); + prevNode = head; + posNext++; + return; + } + // Se il cursore è dopo la TAIL + if (prevNode == tail) { + addLast(data); + prevNode = tail; + posNext++; + return; + } + // Generico + newNode.prev = prevNode; + newNode.next = nextNode; + prevNode.next = newNode; + nextNode.prev = newNode; + lastReturned = null; + posNext++; + size++; + } + + @Override + public void set(E data) { + if (lastReturned == null) throw new NoSuchElementException(); + if (data == null) throw new NullPointerException(); + lastReturned.data = data; + } + } + @Override + public T[] toArray(T[] a) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean containsAll(Collection c) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean addAll(Collection c) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean removeAll(Collection c) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean retainAll(Collection c) { + // TODO Auto-generated method stub + return false; + } + + @Override + public E remove(int index) { + // TODO Auto-generated method stub + return null; + } + + @Override + public int indexOf(Object o) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int lastIndexOf(Object o) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public ListIterator listIterator(int index) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + // TODO Auto-generated method stub + return null; + } }