From 93b8c42c6def399927e4042650a1b61452be2311 Mon Sep 17 00:00:00 2001 From: ifembanefo Date: Tue, 30 May 2023 16:32:12 +0200 Subject: [PATCH] Marmitt Dynamic Strukturen --- 2Semester/DynamicArray/.classpath | 10 ++ 2Semester/DynamicArray/.project | 17 ++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++ 2Semester/DynamicArray/bin/DynamicArray.class | Bin 0 -> 2379 bytes .../DynamicArray/bin/DynamicArrayDemo.class | Bin 0 -> 1065 bytes 2Semester/DynamicArray/src/DynamicArray.java | 88 ++++++++++++++++++ .../DynamicArray/src/DynamicArrayDemo.java | 19 ++++ 2Semester/DynamicHashTable/.classpath | 10 ++ 2Semester/DynamicHashTable/.project | 17 ++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++ .../DynamicHashTable/bin/DynamicArray.class | Bin 0 -> 2379 bytes .../bin/DynamicExtendableHashTable.class | Bin 0 -> 1930 bytes .../bin/DynamicHashTable.class | Bin 0 -> 892 bytes .../bin/DynamicHashTableDemo.class | Bin 0 -> 2136 bytes .../bin/DynamicList$ListElement.class | Bin 0 -> 673 bytes .../DynamicHashTable/bin/DynamicList.class | Bin 0 -> 1770 bytes .../DynamicHashTable/src/DynamicArray.java | 88 ++++++++++++++++++ .../src/DynamicExtendableHashTable.java | 48 ++++++++++ .../src/DynamicHashTable.java | 37 ++++++++ .../src/DynamicHashTableDemo.java | 43 +++++++++ .../DynamicHashTable/src/DynamicList.java | 76 +++++++++++++++ 2Semester/DynamicList/.classpath | 10 ++ 2Semester/DynamicList/.project | 17 ++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++ .../bin/DynamicList$ListElement.class | Bin 0 -> 673 bytes 2Semester/DynamicList/bin/DynamicList.class | Bin 0 -> 1770 bytes .../DynamicList/bin/DynamicListDemo.class | Bin 0 -> 1029 bytes 2Semester/DynamicList/src/DynamicList.java | 76 +++++++++++++++ .../DynamicList/src/DynamicListDemo.java | 20 ++++ 32 files changed, 624 insertions(+) create mode 100644 2Semester/DynamicArray/.classpath create mode 100644 2Semester/DynamicArray/.project create mode 100644 2Semester/DynamicArray/.settings/org.eclipse.core.resources.prefs create mode 100644 2Semester/DynamicArray/.settings/org.eclipse.jdt.core.prefs create mode 100644 2Semester/DynamicArray/bin/DynamicArray.class create mode 100644 2Semester/DynamicArray/bin/DynamicArrayDemo.class create mode 100644 2Semester/DynamicArray/src/DynamicArray.java create mode 100644 2Semester/DynamicArray/src/DynamicArrayDemo.java create mode 100644 2Semester/DynamicHashTable/.classpath create mode 100644 2Semester/DynamicHashTable/.project create mode 100644 2Semester/DynamicHashTable/.settings/org.eclipse.core.resources.prefs create mode 100644 2Semester/DynamicHashTable/.settings/org.eclipse.jdt.core.prefs create mode 100644 2Semester/DynamicHashTable/bin/DynamicArray.class create mode 100644 2Semester/DynamicHashTable/bin/DynamicExtendableHashTable.class create mode 100644 2Semester/DynamicHashTable/bin/DynamicHashTable.class create mode 100644 2Semester/DynamicHashTable/bin/DynamicHashTableDemo.class create mode 100644 2Semester/DynamicHashTable/bin/DynamicList$ListElement.class create mode 100644 2Semester/DynamicHashTable/bin/DynamicList.class create mode 100644 2Semester/DynamicHashTable/src/DynamicArray.java create mode 100644 2Semester/DynamicHashTable/src/DynamicExtendableHashTable.java create mode 100644 2Semester/DynamicHashTable/src/DynamicHashTable.java create mode 100644 2Semester/DynamicHashTable/src/DynamicHashTableDemo.java create mode 100644 2Semester/DynamicHashTable/src/DynamicList.java create mode 100644 2Semester/DynamicList/.classpath create mode 100644 2Semester/DynamicList/.project create mode 100644 2Semester/DynamicList/.settings/org.eclipse.core.resources.prefs create mode 100644 2Semester/DynamicList/.settings/org.eclipse.jdt.core.prefs create mode 100644 2Semester/DynamicList/bin/DynamicList$ListElement.class create mode 100644 2Semester/DynamicList/bin/DynamicList.class create mode 100644 2Semester/DynamicList/bin/DynamicListDemo.class create mode 100644 2Semester/DynamicList/src/DynamicList.java create mode 100644 2Semester/DynamicList/src/DynamicListDemo.java diff --git a/2Semester/DynamicArray/.classpath b/2Semester/DynamicArray/.classpath new file mode 100644 index 0000000..f029363 --- /dev/null +++ b/2Semester/DynamicArray/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/2Semester/DynamicArray/.project b/2Semester/DynamicArray/.project new file mode 100644 index 0000000..950e723 --- /dev/null +++ b/2Semester/DynamicArray/.project @@ -0,0 +1,17 @@ + + + DynamicArray + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/2Semester/DynamicArray/.settings/org.eclipse.core.resources.prefs b/2Semester/DynamicArray/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/2Semester/DynamicArray/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/2Semester/DynamicArray/.settings/org.eclipse.jdt.core.prefs b/2Semester/DynamicArray/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..062ed70 --- /dev/null +++ b/2Semester/DynamicArray/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=19 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=19 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=19 diff --git a/2Semester/DynamicArray/bin/DynamicArray.class b/2Semester/DynamicArray/bin/DynamicArray.class new file mode 100644 index 0000000000000000000000000000000000000000..359b6a62b4594930d92ee46c6e9ee77c5475d1c1 GIT binary patch literal 2379 zcmZuy+fEx-6kW$N#$aqPV4Q|a6Jj97E+(NVO=2KWE-eX{svx8`RmosaU?>=5Od8(v z1O0=h59K8ftyGk%m8w4XQ>uJGRYghHK4-8E&cn>P?0xoLd+l{*{(kfOp8)P*IfQ^h zWcIk|?0Na=Qpq_E!B&XvI8U6BU8lG;va-43=F1Av^6`PY@_267-E)gvw=GtEW_F#! z!<<6Xs<%~i%10$vA#u?@zBZSeq*Kt5GzuLLYdlOATJ48)qf>tWNV2E}g~q&d;N-nB z&op{vx8#)fO9~C+UePO0D#TMYaSW27b%o1y+XjHx?3w+78-_w>1TiEy);Z@E#IbeJ zE4s@^dz)@)&Dq>#S?!Dad1rUsDS5K?H|_Gacc{>^SW6_UNSt>jf&PJxbDn3+bk(6S z7D5Tb!W98~Rl!OPtv3<;wFrV}kXe5O5kzG+7(ol7VWf}_VMyUpwMixS@h&?#qPrYH z1|KLi7v1j`iic&Vm}hN+b@|Cc4Y_`kLI_K$kqDX)rh3kLvcP_bVKjnPL={5Y&f&8A zlwBm^uc)BavXlRI$vHSy)dWQw*dt>0dGM8?OI_;ZtO* zV7izJ3}&O9g>>)+#QE;THHH^(S53$YxTFt`Y2>yLLKS9`UIwOk8JIU1f!`}eny0Vg z*dVBGRuLFFx_F{nXN(vxKchsi?nrcn4{^(nx#q`gWpy|CB!5KEeqp_!o2|JP9)T-0 zfm`bW%Z>#8h>ryo<&iObTp{UMtYjNqOn=G2e#BxjKkK8?+!oDOKbt&2 zCI@w5)8K@kILvzP;4ZUNnG>5pFt!|R{5D{mZ((j)uPITfP--(eGPPxDY75rYCOd|- z2~1W>x~Ib~aV;fsBCB=-SP)%%uT&xX2 z&S$_b{D3K$1h*$R^vTqya@iWQPtZ2pX>%{zX^*Zxvz1;9Jb(KtEvhw2HvA_utHOU$ z_)m(MOuw^e=6sA0ZU_#%RsD@xZ$@a&N#DL z;z?Ymzx+oAc}M5DXV)}u!zX}c@}x9RltdxC;a?<#VHN$CmrLPOd{&`nL3iL4YD$)i{g^CrQiU1zyvIC4TLjNeKsH%6R gLV)<65zva@YXsG6#8m7*bcxm;5KMqj%vWpae^}>$?EnA( literal 0 HcmV?d00001 diff --git a/2Semester/DynamicArray/bin/DynamicArrayDemo.class b/2Semester/DynamicArray/bin/DynamicArrayDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..793a714b9c7bb92bdff24bf4cf3afaa694c24a95 GIT binary patch literal 1065 zcmZuw+fEZv6kVsZOj`%2LtAfn0Tg;sDj=eQRBSadsc2GyQJ+rB1O_`Z&2%94SNs8= z^#P0~#%F)VA28}V)1n>2%Rc+;v-ev2cE11m{1reMk2FLCQq`^_ZL7KNd9qtIZC68- z);)P3OD*Z_l%6&A%%(3eylOd?za}u0%WnxpEAFaKIf6?VOnnKIUD4&c2n9b3bv%+ZhSG#^`PA2WlyqgH)Rm5xcUrTh^7)U%{5 w(7McX4Mvb!wnvXu+-GzWOMEFaxd*(dw0o9yY7c2iAo3FhBCDqg4G~oT0E61^00000 literal 0 HcmV?d00001 diff --git a/2Semester/DynamicArray/src/DynamicArray.java b/2Semester/DynamicArray/src/DynamicArray.java new file mode 100644 index 0000000..cea877a --- /dev/null +++ b/2Semester/DynamicArray/src/DynamicArray.java @@ -0,0 +1,88 @@ +import java.lang.reflect.Array; + +public class DynamicArray { + Class typeOfElement; + private E array[]; + private int count; + private int capacity; + private int iterator; + + public DynamicArray(Class typeOfElement) + { + this(typeOfElement, 10); + } + + @SuppressWarnings("unchecked") + public DynamicArray(Class typeOfElement, int capacity) + { + this.typeOfElement = typeOfElement; + count = 0; + this.capacity = capacity; + array = (E[]) Array.newInstance(typeOfElement, this.capacity); + } + + public void iteratorInit() + { + iterator = 0; + } + + public boolean hasNext() + { + return iterator < count; + } + + public E next() + { + E e = array[iterator]; + iterator++; + return e; + } + + public int count() + { + return count; + } + + public E get(int index) + { + return array[index]; + } + + @SuppressWarnings("unchecked") + public void add(E e) + { + if(count == capacity - 1) + { + int newCapacity = capacity * 2; + E newArray[] = (E[]) Array.newInstance(typeOfElement, this.capacity); + + for(int i = 0; i < capacity; i++) + { + newArray[i] = array[i]; + } + + array = newArray; + capacity = newCapacity; + } + + array[count] = e; + count++; + } + + public E remove(E e) + { + for(int i = 0; i < count; i++) + { + if(e == array[i]) + { + int j = i + 1; + for(; j < count; j++) + array[j - 1] = array[j]; + + array[j - 1] = null; + count--; + } + } + return e; + } +} diff --git a/2Semester/DynamicArray/src/DynamicArrayDemo.java b/2Semester/DynamicArray/src/DynamicArrayDemo.java new file mode 100644 index 0000000..1841f65 --- /dev/null +++ b/2Semester/DynamicArray/src/DynamicArrayDemo.java @@ -0,0 +1,19 @@ + +public class DynamicArrayDemo { + public static void main(String[] args) { + // TODO Auto-generated method stub + DynamicArray myArray = new DynamicArray(String.class); + + myArray.add("Test1"); + myArray.add("Test2"); + myArray.add("Test3"); + + myArray.remove("Test2"); + + myArray.iteratorInit(); + + while(myArray.hasNext()) { + System.out.println(myArray.next()); + } + } +} diff --git a/2Semester/DynamicHashTable/.classpath b/2Semester/DynamicHashTable/.classpath new file mode 100644 index 0000000..f029363 --- /dev/null +++ b/2Semester/DynamicHashTable/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/2Semester/DynamicHashTable/.project b/2Semester/DynamicHashTable/.project new file mode 100644 index 0000000..aecb398 --- /dev/null +++ b/2Semester/DynamicHashTable/.project @@ -0,0 +1,17 @@ + + + DynamicHashTable + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/2Semester/DynamicHashTable/.settings/org.eclipse.core.resources.prefs b/2Semester/DynamicHashTable/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/2Semester/DynamicHashTable/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/2Semester/DynamicHashTable/.settings/org.eclipse.jdt.core.prefs b/2Semester/DynamicHashTable/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..062ed70 --- /dev/null +++ b/2Semester/DynamicHashTable/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=19 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=19 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=19 diff --git a/2Semester/DynamicHashTable/bin/DynamicArray.class b/2Semester/DynamicHashTable/bin/DynamicArray.class new file mode 100644 index 0000000000000000000000000000000000000000..359b6a62b4594930d92ee46c6e9ee77c5475d1c1 GIT binary patch literal 2379 zcmZuy+fEx-6kW$N#$aqPV4Q|a6Jj97E+(NVO=2KWE-eX{svx8`RmosaU?>=5Od8(v z1O0=h59K8ftyGk%m8w4XQ>uJGRYghHK4-8E&cn>P?0xoLd+l{*{(kfOp8)P*IfQ^h zWcIk|?0Na=Qpq_E!B&XvI8U6BU8lG;va-43=F1Av^6`PY@_267-E)gvw=GtEW_F#! z!<<6Xs<%~i%10$vA#u?@zBZSeq*Kt5GzuLLYdlOATJ48)qf>tWNV2E}g~q&d;N-nB z&op{vx8#)fO9~C+UePO0D#TMYaSW27b%o1y+XjHx?3w+78-_w>1TiEy);Z@E#IbeJ zE4s@^dz)@)&Dq>#S?!Dad1rUsDS5K?H|_Gacc{>^SW6_UNSt>jf&PJxbDn3+bk(6S z7D5Tb!W98~Rl!OPtv3<;wFrV}kXe5O5kzG+7(ol7VWf}_VMyUpwMixS@h&?#qPrYH z1|KLi7v1j`iic&Vm}hN+b@|Cc4Y_`kLI_K$kqDX)rh3kLvcP_bVKjnPL={5Y&f&8A zlwBm^uc)BavXlRI$vHSy)dWQw*dt>0dGM8?OI_;ZtO* zV7izJ3}&O9g>>)+#QE;THHH^(S53$YxTFt`Y2>yLLKS9`UIwOk8JIU1f!`}eny0Vg z*dVBGRuLFFx_F{nXN(vxKchsi?nrcn4{^(nx#q`gWpy|CB!5KEeqp_!o2|JP9)T-0 zfm`bW%Z>#8h>ryo<&iObTp{UMtYjNqOn=G2e#BxjKkK8?+!oDOKbt&2 zCI@w5)8K@kILvzP;4ZUNnG>5pFt!|R{5D{mZ((j)uPITfP--(eGPPxDY75rYCOd|- z2~1W>x~Ib~aV;fsBCB=-SP)%%uT&xX2 z&S$_b{D3K$1h*$R^vTqya@iWQPtZ2pX>%{zX^*Zxvz1;9Jb(KtEvhw2HvA_utHOU$ z_)m(MOuw^e=6sA0ZU_#%RsD@xZ$@a&N#DL z;z?Ymzx+oAc}M5DXV)}u!zX}c@}x9RltdxC;a?<#VHN$CmrLPOd{&`nL3iL4YD$)i{g^CrQiU1zyvIC4TLjNeKsH%6R gLV)<65zva@YXsG6#8m7*bcxm;5KMqj%vWpae^}>$?EnA( literal 0 HcmV?d00001 diff --git a/2Semester/DynamicHashTable/bin/DynamicExtendableHashTable.class b/2Semester/DynamicHashTable/bin/DynamicExtendableHashTable.class new file mode 100644 index 0000000000000000000000000000000000000000..6e224338d685f1273e0a0200e57e5add7dd03d55 GIT binary patch literal 1930 zcmaJ?T~`}b6x}yTJ4rfxGzr8&3Z)fHLIA~&YJ(usV50%lU|dyShGYuUhJlp~T7H6m z!R5OzKImEkUDoCD&9(d){tlPA&&=e5r24>Q?z!ilz0W@T4uAap^REEb@TrD?!omp#V3ww*Nwe~dEaOq?8=LVkizIA<4a?yVc7diJA04Jnxin}oF1Dy4~q@+(6qU} zUhd{>G>lfOpb)88`?lenG);x^{{5BRVquj@;hJ%5)GX&zL6vysppC3B{CU|YR<>FW zbK{o+?Fv^{EZcHc6~;3CAca!4%Jv50-cffmv~g57qX;6dV;BjAU?y9QfQ)rq!Bu&C zK}Q5p4HF92dI&|4#*~H|3dwHoP4i)c0xhjKo5rb*Y24%?+x)6zw;aQ+QHi+$He}gD z+*7!qK^N@XI<7%i7%5w}xqWiDXExorD8$M~HKS2AnwHGT4~CortEG@`3-_FfQpfSj zM>$FV_{{&DYs;M&TOpJwWlK?{5SPat9gBFgZ}h%`QZV?~6k}2L*dQXeiAFD19HaJl%Q*H` z2=1HWXacq6aHlE4^~by(HM~onzBSz3DAsXLdd>;UO&#xvwRFodn}&1LEYYyCQPS}~ zK44R}`Gk;(%yWz&rS3@bwvHWqNRcSWwwq6@ex`865U=sN^s|j$3bf}JtsI>+Yv!ia zpeobt>YmP?-@nTw@zKOy-PlfPl+47Yw{N)RvdInF{LM2J@(HBb>3zY9k{!;?kJc}c z@A8mpK#a}AU2LyvxPu+`vAc+}=ON0Thq#EP4&uu$;y=JmIe(5fgjUFvC&phONl{XiC5=38^hmSNp|^myD2Ngu+(m&Tx z(CJ}_6>7 z!8s80R`5rO&pC}*sY~GGob$fV*E#w9=lf3p`*>_2Cs2NM9?8?te=W}jhq5;eESTIq zmY?MAP)0|)?|R39p9n1ZawPpQITsKuf&AbfKw#x#d%nLZu=qTT!sLa3S#LGE{Jf0& zfeiyi2YD<0(oFksWX?Wc+#+q7ixhH`v)E_%jO;dg-*M&elD z>b>p&s@@eG&%H#+bAQ0NMCFUdtZ=Ntv`wi~iFO;*zla6^|T(EB7 z+UzQdWZIyyO)@F7_of_~*&6OrTUo2IwoNzpHHT2LJ9vX50fr_3 literal 0 HcmV?d00001 diff --git a/2Semester/DynamicHashTable/bin/DynamicHashTableDemo.class b/2Semester/DynamicHashTable/bin/DynamicHashTableDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..4847531b5063047d682c19f15e3cd957976d3b1b GIT binary patch literal 2136 zcmZ`)OH&+G6#g#r=%(!?!!SbvAtZrFm<(Y8QB)wr012SOLkH1;_-JN2&@d02X^`># zTDx%R!YVgrWm&oyD6y=p-K5GYS8nnH+*swxvc&K9%)mf~Mc;e7&+9wiIrsFh|NZm} zfSdSCL7hNgtdKF%R${`)ugn=sDRazBXBD^we5=N$5lI=D<;cv^s+q6_yhB#TvWEp+ zU7>ja_h>e0YH*=mhX-DPQ&B5pPH&`_%$(y(z#q*fjMTi5v!w6xN4LFV?Kv-e71!MQhonPeoh#c)cDM(5~R(AxdI}yltj+bl?)5W;e)Au;kLpMrH}s zCScP@52|R;a2X*5T>_0xK8H1QTtQesS(ipB<{j*+!d8{`Re{q-`54)-Qb{wXA%b27 z*A7E;7}L>*>vX?qq&Cc%d(!8XLb50K8(+gXUXTpDc%%fQDI=dBWJ^hnDcMKU$8`|9ZbHFJ z0(v>ltz6D1XqZJzdY+Tes*)*rE;*i;M7=7|AStT0CXKU*>sXLCOt)+^XV}@?Brl>A z+|}_q-eAvX%qpfg#XY9sgK<8S^p{I+C(8Jx*uJVE1$^V};GMV&tct zcpL-^Qg>Bn7Zab`$Sw0~H`chhtWdI$*`EvL6!+<8o7EY;?7Rhe=#vZEw!UJ*53Lni zY7|dSjWx5t&~=NGbYk(5J2O66F>`7`#iqkEsjyy|OV=uzH3AG(m95-R!}Qf&F>#z9 zqjVx>8;P|kW8Fz!K}x}0OSds$stGz#{SA_MsB7%zd zo4xNO$8JcDmvDxwhYa#(1QjhjT_WS%WO|BRXUX)Jlzfdwe2W0SM-V%-dBEB6klMea z6_3z{Klx|*3+?zD9U_2s(TYyd&c9R`A*X(KOEtn8QnG%c18HPf!3J@bG1gh-7U9R+ zJh}KAQjz1y&8S}>51aTNayD#WlRfbp;&=yJ#QO*%DBxY9evdwz=%b|nKJ`no4=DSP nvJSZS2vt?^kpiC(LczF#kJ(=TqD{f<`F}Xy1wNr_9X|aZD;)c; literal 0 HcmV?d00001 diff --git a/2Semester/DynamicHashTable/bin/DynamicList$ListElement.class b/2Semester/DynamicHashTable/bin/DynamicList$ListElement.class new file mode 100644 index 0000000000000000000000000000000000000000..64464a12631b6b016b8cecfedab2d76b578c9125 GIT binary patch literal 673 zcmZ`$%TB{E5S(p8LqnjUyx*@L3P`{is&arLkRmvMxVymuqtvMq7m3f}fRH%w0elo< zT>(l#9J1b-*x63fTRk9@FV(FUrk6@W@v6m)(@o_KVJ`gVA}-m;YYpyd?&O^G2|Fn3 zMG>K7?o?LWBaG&|ST8k{R;J0W>jTQ>HTNDRH?j=EgpW~-c_?DaM+MXDvTh41q0;ia z*J;c2O0;8kUk#H;#MdHK7JreBy__&Ts6BSSb?-9irI9>Qc0!PQ@s8aUq26fi|6N=2 zFGcXrw3g{nEV4{yE>;O6xp|CoD6g^|F?bzNVuA8PUEi^PH>^deXZ49(A2}zoYAUhzX3WB$dGitWj>u9~H z=nu6oeE_Ku5=guO67PHf|4~8Dowegl4T^SV@64TZ&pCJ2`SYKje+96PtsGJc#rsbK zuj{v)em}~=QYbz4o_Nb0FL<>4<-ud!jufmT?HwvyZ6=HIf+UgWjEYk9}R>Vesuaopyc=8{Cl zap_SW6)fcNp2Fq-aoNWEa9FI}3nH2>O2^OyrD|hQSXup(c3VNwlQau(^bXm@OV0Q) zu{-N9$=xpy;kFolhgZQ#+Q3bLuiN;@z#oU2a5){{0fm&fpAB`l_k=GC|5awZGB1Fs zYX~Y|p|ICG3ETRCFKDHN6-y#k!D(#Y8;4mNUsAAlf)( zar$_d%}n#7NFyZ|j8TqJ3KM*I&CbQ_cp{c}UQUjaJn=R273b;dPnfEzQogSe1Tga-~@q2 zu=z1qS&3oa#ybPMWxQ1XGy(b?3% z%bUibE@Q({s=VY+g^1vbOC5_pn3Ga(%CzGKh0Nh1L8R{NKwRw61mS9MSVY_!?FoZ; z?*r~BEMfVK!YxDLZ(>WcH-ACp8#e00R&DVV^EGyAMFv-F{e!KmN&h&MpW{l6i)ALr z#3k3Pi}A5Px7i(FfjxD|-6iKLdDZB}5#cEs?qz!XSmLJ zg%9m_Ws;C8pQ9vE%cy?#?_Z`fvC^A#7g*(IvQF3y^4r8b?o;~%{_K2Cjb9{`)z6gG z2g)*ZqVa|@$%>UpmMDv}hRXO);1x1dHfPiCPgy^OwZXMo$7hTSJX7Jb!JSRUmc*|C DA@3sd literal 0 HcmV?d00001 diff --git a/2Semester/DynamicHashTable/src/DynamicArray.java b/2Semester/DynamicHashTable/src/DynamicArray.java new file mode 100644 index 0000000..cea877a --- /dev/null +++ b/2Semester/DynamicHashTable/src/DynamicArray.java @@ -0,0 +1,88 @@ +import java.lang.reflect.Array; + +public class DynamicArray { + Class typeOfElement; + private E array[]; + private int count; + private int capacity; + private int iterator; + + public DynamicArray(Class typeOfElement) + { + this(typeOfElement, 10); + } + + @SuppressWarnings("unchecked") + public DynamicArray(Class typeOfElement, int capacity) + { + this.typeOfElement = typeOfElement; + count = 0; + this.capacity = capacity; + array = (E[]) Array.newInstance(typeOfElement, this.capacity); + } + + public void iteratorInit() + { + iterator = 0; + } + + public boolean hasNext() + { + return iterator < count; + } + + public E next() + { + E e = array[iterator]; + iterator++; + return e; + } + + public int count() + { + return count; + } + + public E get(int index) + { + return array[index]; + } + + @SuppressWarnings("unchecked") + public void add(E e) + { + if(count == capacity - 1) + { + int newCapacity = capacity * 2; + E newArray[] = (E[]) Array.newInstance(typeOfElement, this.capacity); + + for(int i = 0; i < capacity; i++) + { + newArray[i] = array[i]; + } + + array = newArray; + capacity = newCapacity; + } + + array[count] = e; + count++; + } + + public E remove(E e) + { + for(int i = 0; i < count; i++) + { + if(e == array[i]) + { + int j = i + 1; + for(; j < count; j++) + array[j - 1] = array[j]; + + array[j - 1] = null; + count--; + } + } + return e; + } +} diff --git a/2Semester/DynamicHashTable/src/DynamicExtendableHashTable.java b/2Semester/DynamicHashTable/src/DynamicExtendableHashTable.java new file mode 100644 index 0000000..aa5f303 --- /dev/null +++ b/2Semester/DynamicHashTable/src/DynamicExtendableHashTable.java @@ -0,0 +1,48 @@ +import java.lang.reflect.Array; + +public class DynamicExtendableHashTable { + private Class typeOfElement; + private int capacity; + private DynamicList[] hashTable; + + @SuppressWarnings("unchecked") + public DynamicExtendableHashTable(Class typeOfElement, int capacity) + { + this.typeOfElement = typeOfElement; + this.capacity = capacity; + hashTable = (DynamicList[]) Array.newInstance(DynamicList.class, this.capacity); + } + + public DynamicExtendableHashTable(Class typeOfElement) + { + this(typeOfElement, 100); + } + + public void add(int key, E e) + { + if(hashTable[hashFunction(key)] == null) { + + hashTable[hashFunction(key)] = new DynamicList(); + } + + hashTable[hashFunction(key)].add(e); + } + + public DynamicArray get(int key) + { + DynamicArray array = new DynamicArray(typeOfElement); + + hashTable[hashFunction(key)].iteratorInit(); + + while(hashTable[hashFunction(key)].hasNext()) { + array.add(hashTable[hashFunction(key)].next()); + } + + return array; + } + + private int hashFunction(int key) + { + return key % capacity; + } +} diff --git a/2Semester/DynamicHashTable/src/DynamicHashTable.java b/2Semester/DynamicHashTable/src/DynamicHashTable.java new file mode 100644 index 0000000..f1a3e3c --- /dev/null +++ b/2Semester/DynamicHashTable/src/DynamicHashTable.java @@ -0,0 +1,37 @@ + +public class DynamicHashTable { + + private int capacity; + private Object[] hashTable; + + public DynamicHashTable(int capacity) + { + this.capacity = capacity; + hashTable = new Object[capacity]; + } + + public DynamicHashTable() + { + this(100); + } + + public boolean add(int key, Object o) + { + if(hashTable[hashFunction(key)] == null) { + hashTable[hashFunction(key)] = o; + return true; + } + + return false; + } + + public Object get(int key) + { + return hashTable[hashFunction(key)]; + } + + private int hashFunction(int key) + { + return key % capacity; + } +} diff --git a/2Semester/DynamicHashTable/src/DynamicHashTableDemo.java b/2Semester/DynamicHashTable/src/DynamicHashTableDemo.java new file mode 100644 index 0000000..8acd02b --- /dev/null +++ b/2Semester/DynamicHashTable/src/DynamicHashTableDemo.java @@ -0,0 +1,43 @@ + +public class DynamicHashTableDemo { + + public static void main(String[] args) { + DynamicHashTable dynTable = new DynamicHashTable(5); + + boolean a1 = dynTable.add(0, "Test1"); + boolean a2 = dynTable.add(10, "Test2"); + boolean a3 = dynTable.add(20, "Test3"); + + System.out.println("DynamicHashTable"); + System.out.println(a1 + " " + dynTable.get(0)); + System.out.println(a2 + " " + dynTable.get(10)); + System.out.println(a3 + " " + dynTable.get(20)); + + + DynamicExtendableHashTable dynTable2 = new DynamicExtendableHashTable(String.class, 5); + + dynTable2.add(0, "Test1"); + dynTable2.add(10, "Test2"); + dynTable2.add(20, "Test3"); + + + System.out.println("DynamicExtendableHashTable"); + int keys[] = { 0, 10, 20 }; + for(int i = 0; i < 3; i++) + { + DynamicArray a = new DynamicArray(String.class); + + a = dynTable2.get(keys[i]); + + a.iteratorInit(); + + while(a.hasNext()) { + System.out.print(a.next() + " "); + } + + System.out.println(); + } + + } + +} diff --git a/2Semester/DynamicHashTable/src/DynamicList.java b/2Semester/DynamicHashTable/src/DynamicList.java new file mode 100644 index 0000000..65d4301 --- /dev/null +++ b/2Semester/DynamicHashTable/src/DynamicList.java @@ -0,0 +1,76 @@ + +public class DynamicList { + private class ListElement + { + E content; + ListElement pred; + ListElement succ; + } + private ListElement head; + private ListElement tail; + private ListElement iterator; + + public DynamicList() + { + head = null; + tail = null; + } + + public void iteratorInit() + { + iterator = head; + } + + public boolean hasNext() + { + return iterator != null; + } + + public E next() + { + E e = iterator.content; + iterator = iterator.succ; + return e; + } + + public void add(E element) + { + ListElement le = new ListElement<>(); + + le.content = element; + le.pred = null; + le.succ = null; + + if(head == null) + { + head = le; + tail = le; + } + else + { + le.pred = tail; + tail.succ = le; + tail = le; + } + } + + public E remove(E element) + { + ListElement i = head; + + do + { + if(i.content == element) + { + i.pred.succ = i.succ; + i.succ.pred = i.pred; + + break; + } + i = i.succ; + } + while(i != tail); + + return element; + } +} diff --git a/2Semester/DynamicList/.classpath b/2Semester/DynamicList/.classpath new file mode 100644 index 0000000..f029363 --- /dev/null +++ b/2Semester/DynamicList/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/2Semester/DynamicList/.project b/2Semester/DynamicList/.project new file mode 100644 index 0000000..2f97904 --- /dev/null +++ b/2Semester/DynamicList/.project @@ -0,0 +1,17 @@ + + + DynamicList + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/2Semester/DynamicList/.settings/org.eclipse.core.resources.prefs b/2Semester/DynamicList/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/2Semester/DynamicList/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/2Semester/DynamicList/.settings/org.eclipse.jdt.core.prefs b/2Semester/DynamicList/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..062ed70 --- /dev/null +++ b/2Semester/DynamicList/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=19 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=19 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=19 diff --git a/2Semester/DynamicList/bin/DynamicList$ListElement.class b/2Semester/DynamicList/bin/DynamicList$ListElement.class new file mode 100644 index 0000000000000000000000000000000000000000..64464a12631b6b016b8cecfedab2d76b578c9125 GIT binary patch literal 673 zcmZ`$%TB{E5S(p8LqnjUyx*@L3P`{is&arLkRmvMxVymuqtvMq7m3f}fRH%w0elo< zT>(l#9J1b-*x63fTRk9@FV(FUrk6@W@v6m)(@o_KVJ`gVA}-m;YYpyd?&O^G2|Fn3 zMG>K7?o?LWBaG&|ST8k{R;J0W>jTQ>HTNDRH?j=EgpW~-c_?DaM+MXDvTh41q0;ia z*J;c2O0;8kUk#H;#MdHK7JreBy__&Ts6BSSb?-9irI9>Qc0!PQ@s8aUq26fi|6N=2 zFGcXrw3g{nEV4{yE>;O6xp|CoD6g^|F?bzNVuA8PUEi^PH>^deXZ49(A2}zoYAUhzX3WB$dGitWj>u9~H z=nu6oeE_Ku5=guO67PHf|4~8Dowegl4T^SV@64TZ&pCJ2`SYKje+96PtsGJc#rsbK zuj{v)em}~=QYbz4o_Nb0FL<>4<-ud!jufmT?HwvyZ6=HIf+UgWjEYk9}R>Vesuaopyc=8{Cl zap_SW6)fcNp2Fq-aoNWEa9FI}3nH2>O2^OyrD|hQSXup(c3VNwlQau(^bXm@OV0Q) zu{-N9$=xpy;kFolhgZQ#+Q3bLuiN;@z#oU2a5){{0fm&fpAB`l_k=GC|5awZGB1Fs zYX~Y|p|ICG3ETRCFKDHN6-y#k!D(#Y8;4mNUsAAlf)( zar$_d%}n#7NFyZ|j8TqJ3KM*I&CbQ_cp{c}UQUjaJn=R273b;dPnfEzQogSe1Tga-~@q2 zu=z1qS&3oa#ybPMWxQ1XGy(b?3% z%bUibE@Q({s=VY+g^1vbOC5_pn3Ga(%CzGKh0Nh1L8R{NKwRw61mS9MSVY_!?FoZ; z?*r~BEMfVK!YxDLZ(>WcH-ACp8#e00R&DVV^EGyAMFv-F{e!KmN&h&MpW{l6i)ALr z#3k3Pi}A5Px7i(FfjxD|-6iKLdDZB}5#cEs?qz!XSmLJ zg%9m_Ws;C8pQ9vE%cy?#?_Z`fvC^A#7g*(IvQF3y^4r8b?o;~%{_K2Cjb9{`)z6gG z2g)*ZqVa|@$%>UpmMDv}hRXO);1x1dHfPiCPgy^OwZXMo$7hTSJX7Jb!JSRUmc*|C DA@3sd literal 0 HcmV?d00001 diff --git a/2Semester/DynamicList/bin/DynamicListDemo.class b/2Semester/DynamicList/bin/DynamicListDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..04e11d10482954857fe2ee543dcb016972679acc GIT binary patch literal 1029 zcmZuvU2hUm5IvVd7wER7KvC-_YU@(8*w*?5rD_`!6RajQ81?A_n|3Sgl4WV+ulNUi z)(4tsVtn?`_y>%7?m{itzRaDucV^Dax#!34FW&%cU{gatV0x=-%cfN;S#592Y&sf( z0SswFPEM|H0nTm!Pfr+82C}N0& zkrW8+m~C%a#VH+UaF#R5dR<`F7;4ntgN?$N8v3mO zHuI`&R>w`;A~&}Ao{32#a}r)dZWO?$EQ)2UYFH6S_-u|g*Kr4H0$NMqHOTr1SN}*? zBiz$*9}k$jC)?Zp6jZ<)jwIb({$%2m-(qsTYb!+wOb-7ve>pX(if-#j8R_A~!qA$7 zX^JeKEPJx{?zwCY)D$f{9k*sawUpkHL*h_MUQ&A_4YEwV0|9!JDy_yS$5ZeOEgmBL z$$yU0s%MotL96!@cuq2kU<%W`QN=xG1bD80MeOw@3wukgb z#6IIXy~XcX>ftuMyC44iRG>j9&_&;d5N7i!+9bi|I6|7h^8_{c4Qo6Li2H-3`rvqo kJgdWeD`1_Y6&b0a`!^f(9`PoEz%LjYV(RHJF9LY-7bP9!?EnA( literal 0 HcmV?d00001 diff --git a/2Semester/DynamicList/src/DynamicList.java b/2Semester/DynamicList/src/DynamicList.java new file mode 100644 index 0000000..65d4301 --- /dev/null +++ b/2Semester/DynamicList/src/DynamicList.java @@ -0,0 +1,76 @@ + +public class DynamicList { + private class ListElement + { + E content; + ListElement pred; + ListElement succ; + } + private ListElement head; + private ListElement tail; + private ListElement iterator; + + public DynamicList() + { + head = null; + tail = null; + } + + public void iteratorInit() + { + iterator = head; + } + + public boolean hasNext() + { + return iterator != null; + } + + public E next() + { + E e = iterator.content; + iterator = iterator.succ; + return e; + } + + public void add(E element) + { + ListElement le = new ListElement<>(); + + le.content = element; + le.pred = null; + le.succ = null; + + if(head == null) + { + head = le; + tail = le; + } + else + { + le.pred = tail; + tail.succ = le; + tail = le; + } + } + + public E remove(E element) + { + ListElement i = head; + + do + { + if(i.content == element) + { + i.pred.succ = i.succ; + i.succ.pred = i.pred; + + break; + } + i = i.succ; + } + while(i != tail); + + return element; + } +} diff --git a/2Semester/DynamicList/src/DynamicListDemo.java b/2Semester/DynamicList/src/DynamicListDemo.java new file mode 100644 index 0000000..f550f02 --- /dev/null +++ b/2Semester/DynamicList/src/DynamicListDemo.java @@ -0,0 +1,20 @@ + +public class DynamicListDemo { + + public static void main(String[] args) { + DynamicList dynList = new DynamicList(); + + dynList.add("Test1"); + dynList.add("Test2"); + dynList.add("Test3"); + + dynList.remove("Test2"); + + dynList.iteratorInit(); + + while(dynList.hasNext()) { + System.out.println(dynList.next()); + } + } + +}