powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Реализация связного списка
4 сообщений из 4, страница 1 из 1
Реализация связного списка
    #38752326
stark600
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте. Прошу помочь с реализацией связного списка на Java. Задание звучит так : Создайте простой связанный список/лист для рисунка выше. Ваш список, SingleLinkedList <E> на рисунке, должен быть осуществлением методов в интерфейсе ISingleLinkedList <E> и должен быть построен с узлами типа узла node <E>. В котором mElement – частные переменные и mNextNode- ссылка на следующий узел в списке.

Заранее спасибо ))
...
Рейтинг: 0 / 0
Реализация связного списка
    #38752411
korshun
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
А в чем именно помощь нужна ?
...
Рейтинг: 0 / 0
Реализация связного списка
    #38752492
Фотография mayton
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stark600, ты мог-бы хотя-бы написать следующее для quick-start.
Код: java
1.
2.
3.
4.
public interface ISingleLinkedList<E>{
  void add(E element);
  ....
}


Сообщество поможет дальше. Но избави пожалуйста от рутины тех кто тебе помогает.
...
Рейтинг: 0 / 0
Реализация связного списка
    #38753081
stark600
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
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();
...
Рейтинг: 0 / 0
4 сообщений из 4, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / Реализация связного списка
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]