SlideShare a Scribd company logo
1 of 3
Download to read offline
we using java code /** * DynamicArray.java * * Replace all //TODO tags with your code * * Note
that below the "//TODO" tag there may be * something like "return null;", "return 0;", etc. * That line
is just "stubbed in" so the class * will compile. When you add your code (one or many *
statements), you will want to delete the "stubbed" line. * By "stubbed in" we mean "mocked" or
"faked in" temporarily. * * When testing, construct using the static factory methods:
DynamicList.newEmpty() DynamicList.fromGrowthFactor(growthFactor)
DynamicList.from(arrayElements) */ package model.list; import java.lang.reflect.Array; import
java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiFunction; import
java.util.function.Consumer; import java.util.function.Function; import
model.linearpub.DynamicList; import model.linearpub.StructureIterator; public class
DynamicArray<E> implements DynamicList<E> { //--------------------------------- // Instance Variables
//TODO - declare instance variable(s) //--------------------------------- // Private Constructors /**
Constructs and returns new DynamicArray (no args constructor) */ private DynamicArray() {
this(defaultGrowthFactor()); } /** Constructs and returns new DynamicArray with "aGrowthFactor"
*/ private DynamicArray(double aGrowthFactor) { //TODO -- this is the constructor that should
//initialize the dynamic array as needed } //------------------------------------------------ public static double
defaultGrowthFactor() { //TODO - replace 0 with a good growth factor return 0; } protected static int
defaultInitialCapacity() { //TODO - replace 0 with a good initial capacity return 0; } //--------------------
List Statistics --------------------- /** * Return number of elements in this list. */ @Override public int
size() { //TODO return 0; } /** * Return true is this list contains no elements. */ @Override public
boolean isEmpty() { //TODO return false; } //------------------ Accessing Elements -------------------- /**
* Return element at given index. * Throws IndexOutOfBoundsException if passed index is invalid.
*/ @Override public E get(int index) { //TODO return null; } /** * Return first element * Throws
RuntimeException if list is empty */ @Override public E first() { //TODO return null; } /** * Return
last element * Throws RuntimeException if list is empty */ @Override public E last() { //TODO
return null; } /** * Return a new list containing the elements of this list * between the given index
"start" (inclusive) and * the given index "stop" (exclusive). * Throws IndexOutOfBoundsException if
either passed index is invalid. */ @Override public DynamicList<E> subList(int start, int stop) {
//TODO return null; } /** * Return index of first matching element (where searchFct outputs true) *
Return -1 if no match * Example usage (first list of integers, then employees): * index =
list.find(eaInteger -> eaInteger == 10); * index = employeeList.find(employee -> employee
.getFirstName().equals("Kofi")); */ @Override public int findFirst(Function<E, Boolean> searchFct)
{ //TODO return 0; } /** * Return index of last matching element (where searchFct outputs true) *
E.g., if searching for employee with name "Kofi" and there is a match * at index=3 and index=8,
findLast will return 8 (the last matching index). * Hint: start search at end of list and work
backwards through list. * Return -1 if no match */ @Override public int findLast(Function<E,
Boolean> searchFct) { //TODO return 0; } //------------------- Setting Elements --------------------- /** *
Insert passed arg "newElem" into position "index" * Return previous (replaced) elem at "index" *
Valid "index" values are between 0 and "size - 1" * If "index" is invalid, throws
IndexOutOfBoundsException. */ @Override public E set(int index, E newElem) { //TODO return
null; } //------- Inserting, Appending & Replacing Elements -------- //------------------ (Dynamic
Behaviors) ------------------ /** * Add the passed element to start of list */ @Override public void
addFirst(E newElem) { //TODO } /** * Add the passed element to end of list */ @Override public
void addLast(E newElem) { //TODO } /** * Alias for "addLast" (same functionality) */ @Override
public void add(E newElem) { //TODO } /** * Add all elements from "otherDynList" into "this" list */
@Override public void addAll(DynamicList<E> otherDynList) { //TODO } /** * Add all elements
from passed fixed array "this" list */ @Override public void addAll(E[] array) { //TODO } /** * Shift to
the right the element currently at "insertIndex" (if any) and all elements to the right * Insert passed
arg "newElem" into position "insertIndex" * Valid "insertIndex" values are between 0 and "size" * If
index = "size" then it becomes a simple "add" operation * If "insertIndex" is invalid, throws
IndexOutOfBoundsException */ @Override public void insert(int insertIndex, E newElem) { //TODO
} //------------------- Removing Elements -------------------- //------------------ (Dynamic Behaviors) ---------
--------- /** * Remove first element * Return removed element * Throws RuntimeException if list is
empty */ @Override public E removeFirst() { //TODO return null; } /** * Remove last element *
Return removed element * Throws RuntimeException if list is empty */ @Override public E
removeLast() { //TODO return null; } /** * Reset the list so it is empty. * If list is already empty, then
do nothing * No action is performed on the elements. * */ @Override public void removeAll() {
//TODO } /** * Remove elem at index * Return the removed element * Throws
IndexOutOfBoundsException if passed index is invalid. */ @Override public E removeIndex(int
index) { //TODO return null; } /** * Remove first matching element (where searchFct outputs true) *
Return the removed element * If no match, return null */ @Override public E
removeFirstMatching(Function<E, Boolean> searchFct) { //TODO return null; } //-----------------
Convenience Methods ------------------ /** Return this list as array * This method requires imports of:
* java.lang.reflect.Array; * java.util.concurrent.atomic.AtomicInteger; */ @Override
@SuppressWarnings("unchecked") public E[] toArray() { //This method is completed (no work
needed) if (this.isEmpty()) return (E[]) Array.newInstance(Object.class, 0); StructureIterator<E> iter
= this.iterator(); E[] array = (E[]) Array.newInstance(iter.peek().getClass(), this.size());
AtomicInteger counter = new AtomicInteger(0); this.forEach((each) ->
array[counter.getAndIncrement()] = each); return array; } /** * Returns one-line user-friendly
message about this object * Helpful method especially for debugging. */ @Override public String
toString() { //TODO return null; } /** Prints all elements to console, with newline after each */
@Override public void printAll() { //TODO } /** Iterates over elements in "this" object. For each
element, * performs actionFct (passing element being iterated on) * The generic type "? super E"
means some type that is * a superclass of E (inclusive) */ @Override public void
forEach(Consumer<? super E> actionFct) { //TODO } /** Return new list that is "this" list joined *
with "otherList" list (this list's elements are * first followed by the "otherList" list) */ @Override
public DynamicList<E> join(DynamicList<E> otherList) { //TODO return null; } //----------------- Utility
Methods ------------------ /** * Returns new DynamicList with "new elements". Each new element * is
generated from mapFct invoked with an element from * this list. */ @Override public <T>
DynamicList<T> map(Function<E, T> mapFct) { //TODO return null; } /** * Returns new
DynamicList containing only elements that * result in true when applied to selectFct * Returns new
DynamicList which is elements * selected from this list via selectFct */ @Override public
DynamicList<E> select(Function<E, Boolean> selectFct) { //TODO return null; } /** * Returns new
DynamicList which is this list * with elements rejected via rejectFct */ @Override public
DynamicList<E> reject(Function<E, Boolean> rejectFct) { //TODO return null; } /** Accumulate a
value by iterating over the collection * and accumulating during iteration. * E.g., accumulate a
"sum", or accumulate * a new collection which is the accumulation * of sub-collections obtained
from elements (think * of accumulating all players in a league by * accumulating the players from
each team */ @Override public <T> T accumulate(BiFunction<T, E, T> fct, T initialValue) { //TODO
return null; } //--------------------------------- // Public Constructors (Static Factory Constructor Methods)
// These three methods are completed for you /** Returns a new empty DynamicList */ public static
<T> DynamicList<T> newEmpty() { return new DynamicArray<>(); } /** Return a new empty
DynamicArray with "growthFactor" */ public static <T> DynamicList<T> fromGrowthFactor(double
growthFactor) { return new DynamicArray<>(growthFactor); } /** Return a new DynamicList that
contains all elements from the * param "aFixedArray" */ public static <T> DynamicList<T> from(T[]
aFixedArray) { DynamicList<T> dynamic = new DynamicArray<>(defaultGrowthFactor()); for (T
nextNewElem: aFixedArray) dynamic.add(nextNewElem); return dynamic; } //----------------------------
------------------------------ /*TODO - helper methods (optional -- coder's choice) Helper method simply
means any methods you add (your choice) to make coding easier (i.e., methods that "help" other
methods by doing some of the work. The other methods call the "helper methods". */ }

More Related Content

Similar to we using java code DynamicArrayjava Replace all .pdf

Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
 
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
Java Foundations StackADT-java ---  - Defines the interface to a stack.docxJava Foundations StackADT-java ---  - Defines the interface to a stack.docx
Java Foundations StackADT-java --- - Defines the interface to a stack.docxVictorXUQGloverl
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdffantasiatheoutofthef
 
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxcurwenmichaela
 
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfNote- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfAugstore
 
Note- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfNote- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfStewart29UReesa
 
package ADTs public interface CollectionADTltTgt .pdf
package ADTs public interface CollectionADTltTgt      .pdfpackage ADTs public interface CollectionADTltTgt      .pdf
package ADTs public interface CollectionADTltTgt .pdfsyedabdul78662
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfaccostinternational
 
java write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfjava write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfarjuntelecom26
 
EmptyCollectionException-java -- - Represents the situation in which.docx
EmptyCollectionException-java --  - Represents the situation in which.docxEmptyCollectionException-java --  - Represents the situation in which.docx
EmptyCollectionException-java -- - Represents the situation in which.docxBlakeSGMHemmingss
 
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxNote- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxVictorzH8Bondx
 
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...davidwarner122
 
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdfModifications highlighted in bold lettersDropOutStack.javaim.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdfLalkamal2
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdfConint29
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfmaheshkumar12354
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfConint29
 
Given below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdfGiven below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdfinfo430661
 
All code should be in C++Using the UnsortedList class (UnsortedLis.pdf
All code should be in C++Using the UnsortedList class (UnsortedLis.pdfAll code should be in C++Using the UnsortedList class (UnsortedLis.pdf
All code should be in C++Using the UnsortedList class (UnsortedLis.pdfakashenterprises93
 
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfClass DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfxlynettalampleyxc
 

Similar to we using java code DynamicArrayjava Replace all .pdf (20)

Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdf
 
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
Java Foundations StackADT-java ---  - Defines the interface to a stack.docxJava Foundations StackADT-java ---  - Defines the interface to a stack.docx
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
 
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
 
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfNote- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
 
Note- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfNote- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdf
 
package ADTs public interface CollectionADTltTgt .pdf
package ADTs public interface CollectionADTltTgt      .pdfpackage ADTs public interface CollectionADTltTgt      .pdf
package ADTs public interface CollectionADTltTgt .pdf
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
 
java write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfjava write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdf
 
EmptyCollectionException-java -- - Represents the situation in which.docx
EmptyCollectionException-java --  - Represents the situation in which.docxEmptyCollectionException-java --  - Represents the situation in which.docx
EmptyCollectionException-java -- - Represents the situation in which.docx
 
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxNote- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docx
 
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
 
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdfModifications highlighted in bold lettersDropOutStack.javaim.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdf
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdf
 
Posfix
PosfixPosfix
Posfix
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
 
Given below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdfGiven below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdf
 
All code should be in C++Using the UnsortedList class (UnsortedLis.pdf
All code should be in C++Using the UnsortedList class (UnsortedLis.pdfAll code should be in C++Using the UnsortedList class (UnsortedLis.pdf
All code should be in C++Using the UnsortedList class (UnsortedLis.pdf
 
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfClass DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
 

More from gudduraza28

Wood et al proposed the ecosystem wilting point as a measur.pdf
Wood et al proposed the ecosystem wilting point as a measur.pdfWood et al proposed the ecosystem wilting point as a measur.pdf
Wood et al proposed the ecosystem wilting point as a measur.pdfgudduraza28
 
What command could you use to modify the the etchostname f.pdf
What command could you use to modify the the etchostname f.pdfWhat command could you use to modify the the etchostname f.pdf
What command could you use to modify the the etchostname f.pdfgudduraza28
 
The information above was all that was provided Please help.pdf
The information above was all that was provided Please help.pdfThe information above was all that was provided Please help.pdf
The information above was all that was provided Please help.pdfgudduraza28
 
please answer Iwto0s1adds0t0t1subt2.pdf
please answer  Iwto0s1adds0t0t1subt2.pdfplease answer  Iwto0s1adds0t0t1subt2.pdf
please answer Iwto0s1adds0t0t1subt2.pdfgudduraza28
 
Susan Wilson has 11000 that she can deposit into a savings.pdf
Susan Wilson has 11000 that she can deposit into a savings.pdfSusan Wilson has 11000 that she can deposit into a savings.pdf
Susan Wilson has 11000 that she can deposit into a savings.pdfgudduraza28
 
Leland ve Pylen 1977 ruhunda bir rnek dnn Leland ve .pdf
Leland ve Pylen 1977 ruhunda bir rnek dnn Leland ve .pdfLeland ve Pylen 1977 ruhunda bir rnek dnn Leland ve .pdf
Leland ve Pylen 1977 ruhunda bir rnek dnn Leland ve .pdfgudduraza28
 
Responde las siguientes preguntas Sugerencia aplique la .pdf
Responde las siguientes preguntas  Sugerencia aplique la .pdfResponde las siguientes preguntas  Sugerencia aplique la .pdf
Responde las siguientes preguntas Sugerencia aplique la .pdfgudduraza28
 
QS 1212 LLC Withdrawal of member Camila Dani and Olivia .pdf
QS 1212 LLC Withdrawal of member Camila Dani and Olivia .pdfQS 1212 LLC Withdrawal of member Camila Dani and Olivia .pdf
QS 1212 LLC Withdrawal of member Camila Dani and Olivia .pdfgudduraza28
 
React Router Exercise .pdf
React Router Exercise .pdfReact Router Exercise .pdf
React Router Exercise .pdfgudduraza28
 
QUESTION 1 Which of the following typically supports data ce.pdf
QUESTION 1 Which of the following typically supports data ce.pdfQUESTION 1 Which of the following typically supports data ce.pdf
QUESTION 1 Which of the following typically supports data ce.pdfgudduraza28
 
Por favor responda todas las preguntas 1 Para cualquier p.pdf
Por favor responda todas las preguntas  1 Para cualquier p.pdfPor favor responda todas las preguntas  1 Para cualquier p.pdf
Por favor responda todas las preguntas 1 Para cualquier p.pdfgudduraza28
 
Pfd Company has debt with a yield to maturity of 72 a cos.pdf
Pfd Company has debt with a yield to maturity of 72 a cos.pdfPfd Company has debt with a yield to maturity of 72 a cos.pdf
Pfd Company has debt with a yield to maturity of 72 a cos.pdfgudduraza28
 
a Consider the following Stack of size 7 and draw the stac.pdf
a Consider the following Stack of size 7 and draw the stac.pdfa Consider the following Stack of size 7 and draw the stac.pdf
a Consider the following Stack of size 7 and draw the stac.pdfgudduraza28
 
On April 1 2023 Harry Regal and Meghan Merle formed a part.pdf
On April 1 2023 Harry Regal and Meghan Merle formed a part.pdfOn April 1 2023 Harry Regal and Meghan Merle formed a part.pdf
On April 1 2023 Harry Regal and Meghan Merle formed a part.pdfgudduraza28
 
El aumento de los costos de atencin de la salud hizo que mu.pdf
El aumento de los costos de atencin de la salud hizo que mu.pdfEl aumento de los costos de atencin de la salud hizo que mu.pdf
El aumento de los costos de atencin de la salud hizo que mu.pdfgudduraza28
 
Navarroplease answer all parts BOTH A AND B of the ques.pdf
Navarroplease answer all parts BOTH A AND B of the ques.pdfNavarroplease answer all parts BOTH A AND B of the ques.pdf
Navarroplease answer all parts BOTH A AND B of the ques.pdfgudduraza28
 
MB is a 65yearold male who is being admitted from the em.pdf
MB is a 65yearold male who is being admitted from the em.pdfMB is a 65yearold male who is being admitted from the em.pdf
MB is a 65yearold male who is being admitted from the em.pdfgudduraza28
 
Joe is considering pursuing an MBA degree He has applied to.pdf
Joe is considering pursuing an MBA degree He has applied to.pdfJoe is considering pursuing an MBA degree He has applied to.pdf
Joe is considering pursuing an MBA degree He has applied to.pdfgudduraza28
 
import javautilScanner class Test public static voi.pdf
import javautilScanner class Test      public static voi.pdfimport javautilScanner class Test      public static voi.pdf
import javautilScanner class Test public static voi.pdfgudduraza28
 
If growing lines of Escherichia coli at 20C for 2000 gener.pdf
If growing lines of Escherichia coli at 20C for 2000 gener.pdfIf growing lines of Escherichia coli at 20C for 2000 gener.pdf
If growing lines of Escherichia coli at 20C for 2000 gener.pdfgudduraza28
 

More from gudduraza28 (20)

Wood et al proposed the ecosystem wilting point as a measur.pdf
Wood et al proposed the ecosystem wilting point as a measur.pdfWood et al proposed the ecosystem wilting point as a measur.pdf
Wood et al proposed the ecosystem wilting point as a measur.pdf
 
What command could you use to modify the the etchostname f.pdf
What command could you use to modify the the etchostname f.pdfWhat command could you use to modify the the etchostname f.pdf
What command could you use to modify the the etchostname f.pdf
 
The information above was all that was provided Please help.pdf
The information above was all that was provided Please help.pdfThe information above was all that was provided Please help.pdf
The information above was all that was provided Please help.pdf
 
please answer Iwto0s1adds0t0t1subt2.pdf
please answer  Iwto0s1adds0t0t1subt2.pdfplease answer  Iwto0s1adds0t0t1subt2.pdf
please answer Iwto0s1adds0t0t1subt2.pdf
 
Susan Wilson has 11000 that she can deposit into a savings.pdf
Susan Wilson has 11000 that she can deposit into a savings.pdfSusan Wilson has 11000 that she can deposit into a savings.pdf
Susan Wilson has 11000 that she can deposit into a savings.pdf
 
Leland ve Pylen 1977 ruhunda bir rnek dnn Leland ve .pdf
Leland ve Pylen 1977 ruhunda bir rnek dnn Leland ve .pdfLeland ve Pylen 1977 ruhunda bir rnek dnn Leland ve .pdf
Leland ve Pylen 1977 ruhunda bir rnek dnn Leland ve .pdf
 
Responde las siguientes preguntas Sugerencia aplique la .pdf
Responde las siguientes preguntas  Sugerencia aplique la .pdfResponde las siguientes preguntas  Sugerencia aplique la .pdf
Responde las siguientes preguntas Sugerencia aplique la .pdf
 
QS 1212 LLC Withdrawal of member Camila Dani and Olivia .pdf
QS 1212 LLC Withdrawal of member Camila Dani and Olivia .pdfQS 1212 LLC Withdrawal of member Camila Dani and Olivia .pdf
QS 1212 LLC Withdrawal of member Camila Dani and Olivia .pdf
 
React Router Exercise .pdf
React Router Exercise .pdfReact Router Exercise .pdf
React Router Exercise .pdf
 
QUESTION 1 Which of the following typically supports data ce.pdf
QUESTION 1 Which of the following typically supports data ce.pdfQUESTION 1 Which of the following typically supports data ce.pdf
QUESTION 1 Which of the following typically supports data ce.pdf
 
Por favor responda todas las preguntas 1 Para cualquier p.pdf
Por favor responda todas las preguntas  1 Para cualquier p.pdfPor favor responda todas las preguntas  1 Para cualquier p.pdf
Por favor responda todas las preguntas 1 Para cualquier p.pdf
 
Pfd Company has debt with a yield to maturity of 72 a cos.pdf
Pfd Company has debt with a yield to maturity of 72 a cos.pdfPfd Company has debt with a yield to maturity of 72 a cos.pdf
Pfd Company has debt with a yield to maturity of 72 a cos.pdf
 
a Consider the following Stack of size 7 and draw the stac.pdf
a Consider the following Stack of size 7 and draw the stac.pdfa Consider the following Stack of size 7 and draw the stac.pdf
a Consider the following Stack of size 7 and draw the stac.pdf
 
On April 1 2023 Harry Regal and Meghan Merle formed a part.pdf
On April 1 2023 Harry Regal and Meghan Merle formed a part.pdfOn April 1 2023 Harry Regal and Meghan Merle formed a part.pdf
On April 1 2023 Harry Regal and Meghan Merle formed a part.pdf
 
El aumento de los costos de atencin de la salud hizo que mu.pdf
El aumento de los costos de atencin de la salud hizo que mu.pdfEl aumento de los costos de atencin de la salud hizo que mu.pdf
El aumento de los costos de atencin de la salud hizo que mu.pdf
 
Navarroplease answer all parts BOTH A AND B of the ques.pdf
Navarroplease answer all parts BOTH A AND B of the ques.pdfNavarroplease answer all parts BOTH A AND B of the ques.pdf
Navarroplease answer all parts BOTH A AND B of the ques.pdf
 
MB is a 65yearold male who is being admitted from the em.pdf
MB is a 65yearold male who is being admitted from the em.pdfMB is a 65yearold male who is being admitted from the em.pdf
MB is a 65yearold male who is being admitted from the em.pdf
 
Joe is considering pursuing an MBA degree He has applied to.pdf
Joe is considering pursuing an MBA degree He has applied to.pdfJoe is considering pursuing an MBA degree He has applied to.pdf
Joe is considering pursuing an MBA degree He has applied to.pdf
 
import javautilScanner class Test public static voi.pdf
import javautilScanner class Test      public static voi.pdfimport javautilScanner class Test      public static voi.pdf
import javautilScanner class Test public static voi.pdf
 
If growing lines of Escherichia coli at 20C for 2000 gener.pdf
If growing lines of Escherichia coli at 20C for 2000 gener.pdfIf growing lines of Escherichia coli at 20C for 2000 gener.pdf
If growing lines of Escherichia coli at 20C for 2000 gener.pdf
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 

we using java code DynamicArrayjava Replace all .pdf

  • 1. we using java code /** * DynamicArray.java * * Replace all //TODO tags with your code * * Note that below the "//TODO" tag there may be * something like "return null;", "return 0;", etc. * That line is just "stubbed in" so the class * will compile. When you add your code (one or many * statements), you will want to delete the "stubbed" line. * By "stubbed in" we mean "mocked" or "faked in" temporarily. * * When testing, construct using the static factory methods: DynamicList.newEmpty() DynamicList.fromGrowthFactor(growthFactor) DynamicList.from(arrayElements) */ package model.list; import java.lang.reflect.Array; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; import model.linearpub.DynamicList; import model.linearpub.StructureIterator; public class DynamicArray<E> implements DynamicList<E> { //--------------------------------- // Instance Variables //TODO - declare instance variable(s) //--------------------------------- // Private Constructors /** Constructs and returns new DynamicArray (no args constructor) */ private DynamicArray() { this(defaultGrowthFactor()); } /** Constructs and returns new DynamicArray with "aGrowthFactor" */ private DynamicArray(double aGrowthFactor) { //TODO -- this is the constructor that should //initialize the dynamic array as needed } //------------------------------------------------ public static double defaultGrowthFactor() { //TODO - replace 0 with a good growth factor return 0; } protected static int defaultInitialCapacity() { //TODO - replace 0 with a good initial capacity return 0; } //-------------------- List Statistics --------------------- /** * Return number of elements in this list. */ @Override public int size() { //TODO return 0; } /** * Return true is this list contains no elements. */ @Override public boolean isEmpty() { //TODO return false; } //------------------ Accessing Elements -------------------- /** * Return element at given index. * Throws IndexOutOfBoundsException if passed index is invalid. */ @Override public E get(int index) { //TODO return null; } /** * Return first element * Throws RuntimeException if list is empty */ @Override public E first() { //TODO return null; } /** * Return last element * Throws RuntimeException if list is empty */ @Override public E last() { //TODO return null; } /** * Return a new list containing the elements of this list * between the given index "start" (inclusive) and * the given index "stop" (exclusive). * Throws IndexOutOfBoundsException if either passed index is invalid. */ @Override public DynamicList<E> subList(int start, int stop) { //TODO return null; } /** * Return index of first matching element (where searchFct outputs true) * Return -1 if no match * Example usage (first list of integers, then employees): * index = list.find(eaInteger -> eaInteger == 10); * index = employeeList.find(employee -> employee .getFirstName().equals("Kofi")); */ @Override public int findFirst(Function<E, Boolean> searchFct) { //TODO return 0; } /** * Return index of last matching element (where searchFct outputs true) * E.g., if searching for employee with name "Kofi" and there is a match * at index=3 and index=8, findLast will return 8 (the last matching index). * Hint: start search at end of list and work backwards through list. * Return -1 if no match */ @Override public int findLast(Function<E, Boolean> searchFct) { //TODO return 0; } //------------------- Setting Elements --------------------- /** * Insert passed arg "newElem" into position "index" * Return previous (replaced) elem at "index" * Valid "index" values are between 0 and "size - 1" * If "index" is invalid, throws IndexOutOfBoundsException. */ @Override public E set(int index, E newElem) { //TODO return null; } //------- Inserting, Appending & Replacing Elements -------- //------------------ (Dynamic Behaviors) ------------------ /** * Add the passed element to start of list */ @Override public void
  • 2. addFirst(E newElem) { //TODO } /** * Add the passed element to end of list */ @Override public void addLast(E newElem) { //TODO } /** * Alias for "addLast" (same functionality) */ @Override public void add(E newElem) { //TODO } /** * Add all elements from "otherDynList" into "this" list */ @Override public void addAll(DynamicList<E> otherDynList) { //TODO } /** * Add all elements from passed fixed array "this" list */ @Override public void addAll(E[] array) { //TODO } /** * Shift to the right the element currently at "insertIndex" (if any) and all elements to the right * Insert passed arg "newElem" into position "insertIndex" * Valid "insertIndex" values are between 0 and "size" * If index = "size" then it becomes a simple "add" operation * If "insertIndex" is invalid, throws IndexOutOfBoundsException */ @Override public void insert(int insertIndex, E newElem) { //TODO } //------------------- Removing Elements -------------------- //------------------ (Dynamic Behaviors) --------- --------- /** * Remove first element * Return removed element * Throws RuntimeException if list is empty */ @Override public E removeFirst() { //TODO return null; } /** * Remove last element * Return removed element * Throws RuntimeException if list is empty */ @Override public E removeLast() { //TODO return null; } /** * Reset the list so it is empty. * If list is already empty, then do nothing * No action is performed on the elements. * */ @Override public void removeAll() { //TODO } /** * Remove elem at index * Return the removed element * Throws IndexOutOfBoundsException if passed index is invalid. */ @Override public E removeIndex(int index) { //TODO return null; } /** * Remove first matching element (where searchFct outputs true) * Return the removed element * If no match, return null */ @Override public E removeFirstMatching(Function<E, Boolean> searchFct) { //TODO return null; } //----------------- Convenience Methods ------------------ /** Return this list as array * This method requires imports of: * java.lang.reflect.Array; * java.util.concurrent.atomic.AtomicInteger; */ @Override @SuppressWarnings("unchecked") public E[] toArray() { //This method is completed (no work needed) if (this.isEmpty()) return (E[]) Array.newInstance(Object.class, 0); StructureIterator<E> iter = this.iterator(); E[] array = (E[]) Array.newInstance(iter.peek().getClass(), this.size()); AtomicInteger counter = new AtomicInteger(0); this.forEach((each) -> array[counter.getAndIncrement()] = each); return array; } /** * Returns one-line user-friendly message about this object * Helpful method especially for debugging. */ @Override public String toString() { //TODO return null; } /** Prints all elements to console, with newline after each */ @Override public void printAll() { //TODO } /** Iterates over elements in "this" object. For each element, * performs actionFct (passing element being iterated on) * The generic type "? super E" means some type that is * a superclass of E (inclusive) */ @Override public void forEach(Consumer<? super E> actionFct) { //TODO } /** Return new list that is "this" list joined * with "otherList" list (this list's elements are * first followed by the "otherList" list) */ @Override public DynamicList<E> join(DynamicList<E> otherList) { //TODO return null; } //----------------- Utility Methods ------------------ /** * Returns new DynamicList with "new elements". Each new element * is generated from mapFct invoked with an element from * this list. */ @Override public <T> DynamicList<T> map(Function<E, T> mapFct) { //TODO return null; } /** * Returns new DynamicList containing only elements that * result in true when applied to selectFct * Returns new DynamicList which is elements * selected from this list via selectFct */ @Override public DynamicList<E> select(Function<E, Boolean> selectFct) { //TODO return null; } /** * Returns new DynamicList which is this list * with elements rejected via rejectFct */ @Override public
  • 3. DynamicList<E> reject(Function<E, Boolean> rejectFct) { //TODO return null; } /** Accumulate a value by iterating over the collection * and accumulating during iteration. * E.g., accumulate a "sum", or accumulate * a new collection which is the accumulation * of sub-collections obtained from elements (think * of accumulating all players in a league by * accumulating the players from each team */ @Override public <T> T accumulate(BiFunction<T, E, T> fct, T initialValue) { //TODO return null; } //--------------------------------- // Public Constructors (Static Factory Constructor Methods) // These three methods are completed for you /** Returns a new empty DynamicList */ public static <T> DynamicList<T> newEmpty() { return new DynamicArray<>(); } /** Return a new empty DynamicArray with "growthFactor" */ public static <T> DynamicList<T> fromGrowthFactor(double growthFactor) { return new DynamicArray<>(growthFactor); } /** Return a new DynamicList that contains all elements from the * param "aFixedArray" */ public static <T> DynamicList<T> from(T[] aFixedArray) { DynamicList<T> dynamic = new DynamicArray<>(defaultGrowthFactor()); for (T nextNewElem: aFixedArray) dynamic.add(nextNewElem); return dynamic; } //---------------------------- ------------------------------ /*TODO - helper methods (optional -- coder's choice) Helper method simply means any methods you add (your choice) to make coding easier (i.e., methods that "help" other methods by doing some of the work. The other methods call the "helper methods". */ }