Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions guide/english/java/data-structures/index.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
## Data Structures In Java

#### Overview
```html
This is the definition written in <a href= "https://en.wikipedia.org/wiki/Data_structure" target="_blank">wikipedia</a><br> about data structures in general:
"A data organization, management and storage format that enables efficient access and modification. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.
```

This is the definition written in <a href= "https://en.wikipedia.org/wiki/Data_structure" target="_blank" rel='nofollow'>wikipedia</a> about data structures in general:


"A data organization, management and storage format that enables efficient access and modification. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data."


#### Most popular data structures

- Set [Interface]
Contains only unique elements.
- <a href = "https://docs.oracle.com/javase/7/docs/api/java/util/Set.html" target="_blank" rel='nofollow'>Set</a> [Interface]


Set is an interface which extends Collection. Unordered collection of objects, which does not keep duplicate values. Simply said set is a pair of key and value.

Set is implemented by HashSet, TreeSet, LinkedSet.

_HashSet_ - Underlying data structure is HashTable.
_HashTable_ is data structure, which is based on arrays. Offers fast insertion and searching. Key values are assigned to elements in a Hash Table using a Hash function. A hash function helps calculate the best index an item should go in.
HashTable is thread safe and synchronized => it is slower. Works with multiple threads and does not allow null key.
HashMap is not thread safe and unsynchronized => it is faster. Works with single thread and we can have one key which is null.


_Map.Entry_ – Entry is an interface inside Map interface; we use it for entrySet() – the set of entries: key + value.


_TreeSet_ - This is a set but with alphabetical/ numerical order. Again, we do not have duplicates. We have a tree:
![treeset Example Banner](https://www.cs.wcupa.edu/rkline/assets/img/DS/bst2.png?1264796754)

#### Resources
#### More information
- <a href='https://en.wikipedia.org/wiki/Data_structure' target='_blank' rel='nofollow'>Wikipedia - data structures</a>