Source Code Cross Referenced for SortedList.java in  » Swing-Library » jide-common » com » jidesoft » utils » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jide common » com.jidesoft.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)SortedList.java 1/10/2007
003:         *
004:         * Copyright 2002 - 2007 JIDE Software Inc. All rights reserved.
005:         */
006:
007:        package com.jidesoft.utils;
008:
009:        import java.util.*;
010:
011:        /**
012:         * @author Patrick Gotthardt
013:         */
014:        public class SortedList<E> implements  List<E> {
015:            private Comparator<E> comparator;
016:            private List<E> delegate;
017:
018:            public SortedList(List<E> delegate, Comparator comparator) {
019:                this .delegate = delegate;
020:                this .comparator = comparator;
021:            }
022:
023:            public void add(int index, E element) {
024:                // no indexed insertion supported
025:                add(element);
026:            }
027:
028:            public boolean add(E o) {
029:                int size = delegate.size();
030:                for (int i = 0; i < size; i++) {
031:                    if (comparator.compare(o, delegate.get(i)) > 0) {
032:                        delegate.add(i, o);
033:                        return true;
034:                    }
035:                }
036:                delegate.add(o);
037:                return true;
038:            }
039:
040:            public boolean addAll(Collection<? extends E> c) {
041:                return delegate.addAll(c);
042:            }
043:
044:            public boolean addAll(int index, Collection<? extends E> c) {
045:                return delegate.addAll(index, c);
046:            }
047:
048:            public void clear() {
049:                delegate.clear();
050:            }
051:
052:            public boolean contains(Object o) {
053:                return delegate.contains(o);
054:            }
055:
056:            public boolean containsAll(Collection<?> c) {
057:                return delegate.containsAll(c);
058:            }
059:
060:            @Override
061:            public boolean equals(Object o) {
062:                return delegate.equals(o);
063:            }
064:
065:            public E get(int index) {
066:                return delegate.get(index);
067:            }
068:
069:            @Override
070:            public int hashCode() {
071:                return delegate.hashCode();
072:            }
073:
074:            public int indexOf(Object o) {
075:                return delegate.indexOf(o);
076:            }
077:
078:            public boolean isEmpty() {
079:                return delegate.isEmpty();
080:            }
081:
082:            public Iterator<E> iterator() {
083:                return delegate.iterator();
084:            }
085:
086:            public int lastIndexOf(Object o) {
087:                return delegate.lastIndexOf(o);
088:            }
089:
090:            public ListIterator<E> listIterator() {
091:                return delegate.listIterator();
092:            }
093:
094:            public ListIterator<E> listIterator(int index) {
095:                return delegate.listIterator(index);
096:            }
097:
098:            public E remove(int index) {
099:                return delegate.remove(index);
100:            }
101:
102:            public boolean remove(Object o) {
103:                return delegate.remove(o);
104:            }
105:
106:            public boolean removeAll(Collection<?> c) {
107:                return delegate.removeAll(c);
108:            }
109:
110:            public boolean retainAll(Collection<?> c) {
111:                return delegate.retainAll(c);
112:            }
113:
114:            public E set(int index, E element) {
115:                return delegate.set(index, element);
116:            }
117:
118:            public int size() {
119:                return delegate.size();
120:            }
121:
122:            public List<E> subList(int fromIndex, int toIndex) {
123:                return delegate.subList(fromIndex, toIndex);
124:            }
125:
126:            public Object[] toArray() {
127:                return delegate.toArray();
128:            }
129:
130:            public Object[] toArray(Object[] a) {
131:                return delegate.toArray(a);
132:            }
133:
134:            public static void main(String[] args) {
135:                List<String> sortedList = new SortedList(new ArrayList(),
136:                        new Comparator<String>() {
137:                            public int compare(String o1, String o2) {
138:                                return o2.compareTo(o1);
139:                            }
140:                        });
141:                sortedList.add("test");
142:                sortedList.add("aaa");
143:                sortedList.add("ddd");
144:                sortedList.add("ccc");
145:                for (String aSortedList : sortedList) {
146:                    String s = (String) aSortedList;
147:                    System.out.println(s);
148:                }
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.