Android Browser bookmark insertion de-weight algorithm

Source: Internet
Author: User

about the browser Insert bookmark repeat problem has not found a good algorithm, but only temporarily write a stupid way, also please pass by the great God pointing twos, my logic is to insert the bookmark into a collection, before inserting the first query the local browser bookmarks collection, A double loop is used to determine if the URL and title are the same, which is repeated, then added to a new set, and the loop is completed from the collection that needs to be inserted remove the duplicate collection

The code is as follows:

Private list<bookmark> removerepeat (list<bookmark> restore,list<bookmark> local) {List< Bookmark> newlist=new arraylist<bookmark> (); for (int i=0;i<restore.size (); i++) {String title=restore.get (i). GetTitle (); String Url=restore.get (i). GETURL (); for (int j=0;j<local.size (); j + +) {//title and URL are the same at the same time, it is determined to repeat if (Title.trim (). Equals (Local.get (j). GetTitle (). Trim ()) &&url.trim (). Equals (Local.get (j). GETURL (). Trim ())) {Newlist.add ( Restore.get (i)); break;}}} If there are duplicates, remove all duplicates by removing the IF (newlist.size () >0) {Restore.removeall (newlist);} return restore;}

Android Browser bookmark insertion de-weight algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.