VersionControlSystem
There are a few ways:
LinkedList + Hash: Map (
fileId: File) withpreviousFile: Filein theFilefor previous version- Time complexity:
- $O(1)$ for removal and add
- $O(n)$ for searching
- Improvement could be Skip List but increase complexity
- Store less file in our Cache
- Time complexity:
Map (
fileId: File) withstatic previousVersion: LinkedHashMap {version: File}inFilefor previous version across all files- Time complexity :
- $O(1)$ for removal and Add
- $O(1)$ for searching
- Concurrency could be a problem since there is only
Synchronised library - However version are not sorted
>[!note]
NOTE try to avoid this one because if we need to store the latest version,LinkedHashMapwould not have the latest key API
- Time complexity :
Map (
fileId: File) withstatic previousVersion: TreeMap {version: File}forFilefor previous version accross all files- Time complexity:
- $O(logn)$ for everything
- Can use ConcurrentSkipListMap however will also be $O(logn)$
- Versions are sorted
- Recommended because it support a lot of api, last entry, tailMap, etc
- Time complexity:
