Re: Data Structures question
| From: | Robin Johnson | Date: | Sat, 16 Nov 2002 04:28:13 +0000 |
| Subject: | Re: Data Structures question | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-10864@lists.php.net to get a copy of this message | ||
On Sat, Nov 16, 2002 at 12:07:11AM +0100, Stig S. Bakken wrote:
> I've been thinking about a few of these classes too, especially Queue
> and Iterator.
Great.
> So then it's down to naming. Some suggestions (in
> addition to Structure_*):
>
> Data_*
> DS_* (data structure)
Data_ has conceptual connotations that we handle specific types of Data.
So that leaves DS_* or Structure_*.
Personally, +1 for Structure_*.
Vote for code clarity rather than short names.
> What are Perl and Java calling these?
I don't know about Perl myself (I'm not a Perl coder, only
C/C++/Java/PHP).
In java
all of the classes belong to java.util.*;
The reason I asked about abstract classes and the like
is that for maintence and design reasons, I'd like to go the fully
engineered way for using things like Java does it looks like a bloated
system, but in reality it is a very good example of code refactoring.
The only documentation I find about abstract classes/functions in PHP
is this posting:
http://www.zend.com/lists/php-dev/200211/msg00300.html
How does one go about putting together abstract functions from that?
is there a AbstractFunctionException that could be thrown?
This is a total overview of the Java data structure system
For more details, have a look at:
http://java.sun.com/j2se/1.4/docs/api/java/util/package-frame.html
I have left out two classes from Java that I considered of minimal
value in PHP, for various reasons (WeakHashMap, Hashtable)
Interfaces:
Collection
List extends Collection
Set extends Collection
SortedSet extends Set
Map
SortedMap extend Map
Iterator
Implementation Helper Classes:
AbstractCollection implements Collection - skeletal (mostly abstract)
AbstractList implements List extends AbstractCollection - skeletal (mostly abstract)
AbstractSequentialList implements List extends AbstractList - skeletal (mostly abstract)
AbstractSet implements Set extends AbstractCollection - skeletal (mostly abstract)
AbstractMap implements Map - skeletal (mostly abstract)
Classes (ones that can be used):
Vector implements List extends AbstractList - growable array of objects
ArrayList implements List extends AbstractList - Resizable-array implementation of the List
interface
LinkedList implements List extends AbstractSequentialList - doubly linked list
Stack extends Vector - standard stack
HashSet implements Set extends AbstractSet - composition HashMap
TreeSet implements SortedSet extends AbstractSet - composition TreeMap
LinkedHashSet implements Set extends HashSet - better performance HashSet for some operations
HashMap implements Map extends AbstractMap - Hash table based implementation
LinkedHashMap extends HashMap - like LinkedHashSet, but for Maps
IdentityHashMap implements Map - uses reference-equality instead object-equality
TreeMap implements SortedMap extends AbstractMap - Red-Black Tree using keys
Stuff not currently in Java directly, but trivial to implement using above
classes:
Queue - composition LinkedList
Deque - composition LinkedList
PriorityQueue - ?
Further questions for doing Iterators. Does PHP support
inner/anonymous classes?
I found this old posting:
http://www.phpbuilder.com/mail/php-developer-list/199909/0739.php
How much of this has changed with ZE2 ?
--
Robin Hugh Johnson
E-Mail : robbat2@orbis-terrarum.net
Home Page : http://www.orbis-terrarum.net/?l=people.robbat2
ICQ# : 30269588 or 41961639
GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85