SlideShare a Scribd company logo
1 of 5
Download to read offline
we using java dynamicArray
package model.linearpub;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
public interface DynamicList<E> {
//-------------------- List Statistics ---------------------
/**
* Return number of elements in this list.
*/
int size();
/**
* Return true is this list contains no elements.
*/
boolean isEmpty();
//------------------ Accessing Elements --------------------
/**
* Return element at given index.
* Throws IndexOutOfBoundsException if passed index is invalid.
*/
E get(int index);
/**
* Return first element
* Throws RuntimeException if list is empty
*/
E first();
/**
* Return last element
* Throws RuntimeException if list is empty
*/
E last();
/**
* 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.
*/
DynamicList<E> subList(int start, int stop);
/**
* 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"));
*/
int findFirst(Function<E, Boolean> searchFct);
/**
* 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
*/
int findLast(Function<E, Boolean> searchFct);
//------------------- 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.
*/
E set(int index, E newElem);
//------- Inserting, Appending & Replacing Elements --------
//------------------ (Dynamic Behaviors) ------------------
/**
* Add the passed element to start of list
*/
void addFirst(E newElem);
/**
* Add the passed element to end of list
*/
void addLast(E newElem);
/**
* Alias for "addLast" (same functionality)
*/
void add(E newElem);
/**
* Add all elements from "otherDynList" into "this" list
*/
void addAll(DynamicList<E> otherDynList);
/**
* Add all elements from passed fixed array "this" list
*/
void addAll(E[] array);
/**
* 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
*/
void insert(int insertIndex, E newElem);
//------------------- Removing Elements --------------------
//------------------ (Dynamic Behaviors) ------------------
/**
* Remove first element
* Return removed element
* Throws RuntimeException if list is empty
*/
E removeFirst();
/**
* Remove last element
* Return removed element
* Throws RuntimeException if list is empty
*/
E removeLast();
/**
* Reset the list so it is empty.
* If list is already empty, then do nothing
* No action is performed on the elements.
*
*/
void removeAll();
/**
* Remove elem at index
* Return the removed element
* Throws IndexOutOfBoundsException if passed index is invalid.
*/
E removeIndex(int index);
/**
* Remove first matching element (where searchFct outputs true)
* Return the removed element
* If no match, return null
*/
E removeFirstMatching(Function<E, Boolean> searchFct);
//----------------- Convenience Methods ------------------
/**
* Return this list as an array (maintain same order of elements)
*/
E[] toArray();
/**
* Returns one-line user-friendly message about this object
* Helpful method especially for debugging.
*/
String toString();
/** Prints all elements to console, with newline after each */
void printAll();
/** 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)
*/
void forEach(Consumer<? super E> actionFct);
/** Return new list that is "this" list joined
* with "otherList" list (this list's elements are
* first followed by the "otherList" list)
*/
DynamicList<E> join(DynamicList<E> otherList);
//----------------- Utility Methods ------------------
/**
* Returns new DynamicList with "new elements". Each new element
* is generated from mapFct invoked with an element from
* this list.
*/
<T> DynamicList<T> map(Function<E, T> mapFct);
/**
* 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
*/
DynamicList<E> select(Function<E, Boolean> selectFct);
/**
* Returns new DynamicList which is this list
* with elements rejected via rejectFct
*/
DynamicList<E> reject(Function<E, Boolean> rejectFct);
/** 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
*/
<T> T accumulate(BiFunction<T, E, T> fct, T initialValue);
//------------------- Optional Methods ---------------------
/**
* Return iterator on this list
*/
default StructureIterator<E> iterator() { throw notImplemented(); }
static RuntimeException notImplemented() {
return new RuntimeException("Not Implemented");
}
}

More Related Content

Similar to we using java dynamicArray package modellinearpub imp.pdf

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
Augstore
 
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
Stewart29UReesa
 
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
VictorzH8Bondx
 
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
akashenterprises93
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
accostinternational
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdf
Conint29
 
package ADTs public interface CollectionADTltTgt .pdf
package ADTs public interface CollectionADTltTgt      .pdfpackage ADTs public interface CollectionADTltTgt      .pdf
package ADTs public interface CollectionADTltTgt .pdf
syedabdul78662
 
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
VictorXUQGloverl
 
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
seoagam1
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
JamesPXNNewmanp
 
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
curwenmichaela
 
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
Conint29
 
package linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfpackage linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdf
arcellzone
 
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
info430661
 
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdfpackage com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
aptind
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
kingsandqueens3
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
ARCHANASTOREKOTA
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
ravikapoorindia
 

Similar to we using java dynamicArray package modellinearpub imp.pdf (20)

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
 
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
 
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
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdf
 
package ADTs public interface CollectionADTltTgt .pdf
package ADTs public interface CollectionADTltTgt      .pdfpackage ADTs public interface CollectionADTltTgt      .pdf
package ADTs public interface CollectionADTltTgt .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
 
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...
 
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
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdf
 
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
 
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
 
package linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfpackage linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.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
 
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdfpackage com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
 

More from adityagupta3310

We studied photosynthesis in prokaryotes and eukaryotes Pho.pdf
We studied photosynthesis in prokaryotes and eukaryotes Pho.pdfWe studied photosynthesis in prokaryotes and eukaryotes Pho.pdf
We studied photosynthesis in prokaryotes and eukaryotes Pho.pdf
adityagupta3310
 
What is one of the functions of the large intestine Multipl.pdf
What is one of the functions of the large intestine Multipl.pdfWhat is one of the functions of the large intestine Multipl.pdf
What is one of the functions of the large intestine Multipl.pdf
adityagupta3310
 

More from adityagupta3310 (20)

We will now try to repeat this exercise for the Edmonton Riv.pdf
We will now try to repeat this exercise for the Edmonton Riv.pdfWe will now try to repeat this exercise for the Edmonton Riv.pdf
We will now try to repeat this exercise for the Edmonton Riv.pdf
 
Week 6 Conditional Statements Activity 3 OddEven 10 pts .pdf
Week 6  Conditional Statements Activity 3 OddEven 10 pts .pdfWeek 6  Conditional Statements Activity 3 OddEven 10 pts .pdf
Week 6 Conditional Statements Activity 3 OddEven 10 pts .pdf
 
Web Services What are Web Services Your task is to wr.pdf
Web Services       What are Web Services Your task is to wr.pdfWeb Services       What are Web Services Your task is to wr.pdf
Web Services What are Web Services Your task is to wr.pdf
 
Web Cites Research projects a rate of return of 21 percent o.pdf
Web Cites Research projects a rate of return of 21 percent o.pdfWeb Cites Research projects a rate of return of 21 percent o.pdf
Web Cites Research projects a rate of return of 21 percent o.pdf
 
We studied photosynthesis in prokaryotes and eukaryotes Pho.pdf
We studied photosynthesis in prokaryotes and eukaryotes Pho.pdfWe studied photosynthesis in prokaryotes and eukaryotes Pho.pdf
We studied photosynthesis in prokaryotes and eukaryotes Pho.pdf
 
We reviewed a number of different Artificial Intelligence vi.pdf
We reviewed a number of different Artificial Intelligence vi.pdfWe reviewed a number of different Artificial Intelligence vi.pdf
We reviewed a number of different Artificial Intelligence vi.pdf
 
We have two same boxes One box has 10 balls numbered 1 to 1.pdf
We have two same boxes One box has 10 balls numbered 1 to 1.pdfWe have two same boxes One box has 10 balls numbered 1 to 1.pdf
We have two same boxes One box has 10 balls numbered 1 to 1.pdf
 
We studied Mission Statements in Chapter 2 Our College Of B.pdf
We studied Mission Statements in Chapter 2 Our College Of B.pdfWe studied Mission Statements in Chapter 2 Our College Of B.pdf
We studied Mission Statements in Chapter 2 Our College Of B.pdf
 
What is the confidence level of each of the following confid.pdf
What is the confidence level of each of the following confid.pdfWhat is the confidence level of each of the following confid.pdf
What is the confidence level of each of the following confid.pdf
 
We will evaluate the impact of electronic networks and commu.pdf
We will evaluate the impact of electronic networks and commu.pdfWe will evaluate the impact of electronic networks and commu.pdf
We will evaluate the impact of electronic networks and commu.pdf
 
Welcome to intmath This program will add subtract multiply.pdf
Welcome to intmath This program will add subtract multiply.pdfWelcome to intmath This program will add subtract multiply.pdf
Welcome to intmath This program will add subtract multiply.pdf
 
What is the cost of equity of Trifecta Inc if its beta is .pdf
What is the cost of equity of Trifecta Inc if its beta is .pdfWhat is the cost of equity of Trifecta Inc if its beta is .pdf
What is the cost of equity of Trifecta Inc if its beta is .pdf
 
What is the closeness centrality of nodes ABC a 58.pdf
What is the closeness centrality of nodes ABC  a 58.pdfWhat is the closeness centrality of nodes ABC  a 58.pdf
What is the closeness centrality of nodes ABC a 58.pdf
 
What is the beta of each of the stocks shown below Negativ.pdf
What is the beta of each of the stocks shown below Negativ.pdfWhat is the beta of each of the stocks shown below Negativ.pdf
What is the beta of each of the stocks shown below Negativ.pdf
 
What is the BigO time complexity value of the following c.pdf
What is the BigO time complexity value of the following c.pdfWhat is the BigO time complexity value of the following c.pdf
What is the BigO time complexity value of the following c.pdf
 
What is the attribute of child view so that it align to pare.pdf
What is the attribute of child view so that it align to pare.pdfWhat is the attribute of child view so that it align to pare.pdf
What is the attribute of child view so that it align to pare.pdf
 
What is Social Control Theory How do landlords voluntarily.pdf
What is Social Control Theory  How do landlords voluntarily.pdfWhat is Social Control Theory  How do landlords voluntarily.pdf
What is Social Control Theory How do landlords voluntarily.pdf
 
What is the active place and the allosteric point What is t.pdf
What is the active place and the allosteric point What is t.pdfWhat is the active place and the allosteric point What is t.pdf
What is the active place and the allosteric point What is t.pdf
 
What is one of the functions of the large intestine Multipl.pdf
What is one of the functions of the large intestine Multipl.pdfWhat is one of the functions of the large intestine Multipl.pdf
What is one of the functions of the large intestine Multipl.pdf
 
web designplease help me urgent 9 If Lindsey placed tw.pdf
web designplease help me urgent 9 If Lindsey placed tw.pdfweb designplease help me urgent 9 If Lindsey placed tw.pdf
web designplease help me urgent 9 If Lindsey placed tw.pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

we using java dynamicArray package modellinearpub imp.pdf

  • 1. we using java dynamicArray package model.linearpub; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; public interface DynamicList<E> { //-------------------- List Statistics --------------------- /** * Return number of elements in this list. */ int size(); /** * Return true is this list contains no elements. */ boolean isEmpty(); //------------------ Accessing Elements -------------------- /** * Return element at given index. * Throws IndexOutOfBoundsException if passed index is invalid. */ E get(int index); /** * Return first element * Throws RuntimeException if list is empty */ E first(); /** * Return last element * Throws RuntimeException if list is empty */ E last(); /** * 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. */
  • 2. DynamicList<E> subList(int start, int stop); /** * 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")); */ int findFirst(Function<E, Boolean> searchFct); /** * 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 */ int findLast(Function<E, Boolean> searchFct); //------------------- 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. */ E set(int index, E newElem); //------- Inserting, Appending & Replacing Elements -------- //------------------ (Dynamic Behaviors) ------------------ /** * Add the passed element to start of list */ void addFirst(E newElem); /** * Add the passed element to end of list */ void addLast(E newElem); /**
  • 3. * Alias for "addLast" (same functionality) */ void add(E newElem); /** * Add all elements from "otherDynList" into "this" list */ void addAll(DynamicList<E> otherDynList); /** * Add all elements from passed fixed array "this" list */ void addAll(E[] array); /** * 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 */ void insert(int insertIndex, E newElem); //------------------- Removing Elements -------------------- //------------------ (Dynamic Behaviors) ------------------ /** * Remove first element * Return removed element * Throws RuntimeException if list is empty */ E removeFirst(); /** * Remove last element * Return removed element * Throws RuntimeException if list is empty */ E removeLast(); /** * Reset the list so it is empty. * If list is already empty, then do nothing * No action is performed on the elements. *
  • 4. */ void removeAll(); /** * Remove elem at index * Return the removed element * Throws IndexOutOfBoundsException if passed index is invalid. */ E removeIndex(int index); /** * Remove first matching element (where searchFct outputs true) * Return the removed element * If no match, return null */ E removeFirstMatching(Function<E, Boolean> searchFct); //----------------- Convenience Methods ------------------ /** * Return this list as an array (maintain same order of elements) */ E[] toArray(); /** * Returns one-line user-friendly message about this object * Helpful method especially for debugging. */ String toString(); /** Prints all elements to console, with newline after each */ void printAll(); /** 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) */ void forEach(Consumer<? super E> actionFct); /** Return new list that is "this" list joined * with "otherList" list (this list's elements are * first followed by the "otherList" list) */ DynamicList<E> join(DynamicList<E> otherList);
  • 5. //----------------- Utility Methods ------------------ /** * Returns new DynamicList with "new elements". Each new element * is generated from mapFct invoked with an element from * this list. */ <T> DynamicList<T> map(Function<E, T> mapFct); /** * 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 */ DynamicList<E> select(Function<E, Boolean> selectFct); /** * Returns new DynamicList which is this list * with elements rejected via rejectFct */ DynamicList<E> reject(Function<E, Boolean> rejectFct); /** 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 */ <T> T accumulate(BiFunction<T, E, T> fct, T initialValue); //------------------- Optional Methods --------------------- /** * Return iterator on this list */ default StructureIterator<E> iterator() { throw notImplemented(); } static RuntimeException notImplemented() { return new RuntimeException("Not Implemented"); } }