[Java] How to remove a matching Custom Class from Treasure?

Asked 2 years ago, Updated 2 years ago, 27 views

I'm working on a program to manage records, and I'm using TreeSet, and I'll say custom class is Man. The method of sorting Man in TreeSet is defined by the compareTomethod.

`class Man implements Comparable {

private String name; private int gender;

(...)

public int compareTo(Man compare) { return this.name - compare.getName(); }

}`

It's sorted like this.

For example, here:

I'm trying to perform this function, but I get stuck whenever I study Data Structure. ManList.remove(manName); of course not, but I think running time will be exceeded to find and remove Iterator in TreeSet. In this way, how can I find the corresponding instance with only the attribute of the object and delete it from the data structure?

I'm studying bst, so I don't want to use other data structures (hashmaps, etc.)!

java

2022-09-22 20:29

1 Answers

Just a simple tree is difficult and requires additional devices. For example, rdbms uses an additional device called Index.

It's a file I searched before. https://code.google.com/archive/p/indexed-tree-map/

Analyze the data above.


2022-09-22 20:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.