|
|
|
Реализация связного списка
|
|||
|---|---|---|---|
|
#18+
Здравствуйте. Прошу помочь с реализацией связного списка на Java. Задание звучит так : Создайте простой связанный список/лист для рисунка выше. Ваш список, SingleLinkedList <E> на рисунке, должен быть осуществлением методов в интерфейсе ISingleLinkedList <E> и должен быть построен с узлами типа узла node <E>. В котором mElement – частные переменные и mNextNode- ссылка на следующий узел в списке. Заранее спасибо )) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 20.09.2014, 12:24 |
|
||
|
Реализация связного списка
|
|||
|---|---|---|---|
|
#18+
А в чем именно помощь нужна ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 20.09.2014, 15:22 |
|
||
|
Реализация связного списка
|
|||
|---|---|---|---|
|
#18+
stark600, ты мог-бы хотя-бы написать следующее для quick-start. Код: java 1. 2. 3. 4. Сообщество поможет дальше. Но избави пожалуйста от рутины тех кто тебе помогает. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 20.09.2014, 17:47 |
|
||
|
Реализация связного списка
|
|||
|---|---|---|---|
|
#18+
mayton, прошу прощения. С добавлением в конец списка разобрался вроде public interface ISingleLinkedList<E> { private int N; //Size of the List private Node<E> first; // First element of the List private static class Node<E> //helper class { private E mElement; private Node<E> mNextNode; } public ISingleLinkedList { //inizialization empty List first = null; N=0; } /** * Appends the specified element to the end of this list. * @param element element to be appended to the end of this list */ public void add(E element); { Node<E> oldfirst = first; first = new Node<E>; first.mElement = element; oldfirst.mNextNode = first; N++; } /** * Inserts the specified element at the specified index in this list. * @param index index at which the specified element is to be inserted * @param element element to be inserted * @throws IndexOutOfBoundsException if index < 0 or index > size() */ public void add(int index, E element) throws IndexOutOfBoundsException; public void clear(); /** * Returns the element at the specified index in this list. * @param index index of the element to return * @return the element at the specified index in this list * @throws IndexOutOfBoundsException if index < 0 or index >= size() */ public E get(int index) throws IndexOutOfBoundsException; /** * Returns the index of the first occurrence of the specified element in this * list, or -1 if this list does not contain the element. More formally, * returns the lowest index i such that (E == null ? get(i) == null : * E.equals(get(i))), or -1 if there is no such index. * @param element element to search for * @return the index of the first occurrence of the specified element in * this list, or -1 if this list does not contain the element */ public int indexOf(E element); /** * Removes the element at the specified index in this list. Returns the * element that was removed from the list. * @param index the index of the element to be removed * @return the element previously at the specified index * @throws IndexOutOfBoundsException if index < 0 or index >= size() */ public E remove(int index) throws IndexOutOfBoundsException; /** * Replaces the element at the specified index in this list with the * specified element. * @param index index of the element to replace * @param element element to be stored at the specified index * @return the element previously at the specified index * @throws IndexOutOfBoundsException if index < 0 or index >= size() */ public E set(int index, E element) throws IndexOutOfBoundsException; /** * Returns the number of elements in this list. * @return the number of elements in this list */ public int size(); /** * Returns an array containing all of the elements in this list in proper * sequence (from first to last element), or null if this list is empty. * @return an array containing all of the elements in this list in proper * sequence, or null if this list is empty */ public E[] toArray(); /** * Returns a string representation of this list, containing the String * representation of each element, or an empty string if this list is empty. * @return a string representation of this list, or an empty string if this * list is empty */ @Override public String toString(); ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.09.2014, 22:05 |
|
||
|
|

start [/forum/topic.php?fid=59&gotonew=1&tid=2126569]: |
0ms |
get settings: |
9ms |
get forum list: |
19ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
148ms |
get topic data: |
13ms |
get first new msg: |
9ms |
get forum data: |
3ms |
get page messages: |
61ms |
get tp. blocked users: |
2ms |
| others: | 244ms |
| total: | 514ms |

| 0 / 0 |
