Kernel list implementation

Hi,
Does the Solaris kernel (9 and 10) provide any sort of general list implementation that can be used for driver development? I've looked at "Writing Device Drivers", and unless I missed it, I can't find anything about such an interface in there.
Thanks,
Andrew

There isn't one in the DDI. Solaris 10 has one in sys/list.h but we have not yet made it
part of the DDI.
-Mike

Similar Messages

  • List implementation where remove(Object) is fast?

    Does anyone know of an implementation of the java.util.List interface where the the method boolean remove(Object o) is much faster than traversing through the list until it finds the right one? Perhaps something that takes advantage of the hash code of the object being removed?
    Thanks

    So you want a List that acts like a Map?
    Couldn't you just use a Map?
    Explain your problem domain better and we shall help
    you see the light.
    Well no - I would simply like a List that acts like a List, and whose remove(Object) method is faster than just scanning through each element.
    I only mentioned use of the hash code as one way this could be implemented. To expand on that: Currently the LinkedList class internally maintains a list of Entry objects. Each of these objects has a reference to the previous and next Entry and the 'current' list element object. The problem is that the remove(Object) method has to go through each Entry one by one, searching for a list element that equals the object to be removed. To fix this problem the list implementation could also maintain a HashMap whose 'keys' are the list elements and whose 'values' are a (secondary) list of Entry objects associated with that key. Now the remove(Object) method could use the object to be removed to look up the 'list of associated Entry objects'. The first Entry in this (secondary) list is the one that needs to be removed.
    But perhaps it's best if I describe the overlying problem: I want to write a program that randomly generates integers at the rate of about 10 per second. For each integer the program should calculate how many times in the past hour that number has been generated. What's the fastest way to calculate this?

  • Problems with List Implementation

    I have a list implementation that is like a linked list but contains 'n' elements in each node, set to 8 by default.
    The list has a head node, and a tail node.
    This is a revisit on an assignment, I'm trying to fix it.
    The problem is when a number of elements have been added and then deleted from the end of the list. Then more elements are added.
    I'm using a JUnit test case to test this, and what happens is about 25 elements are added and removed, but when it gets to adding a new elements after recently deleting some items towards the end of the list. My list fails because, I am unable to assign value to my tail from within my iterator.
    The compiletime error I get is:
    Type mismatch: cannot convert from chunklist.ChunkList<T>.Chunk<T> to chunklist.ChunkList<T>.Chunk<T>
    I need to assign my tail to the previous Chunk (node), because in my iterator when I delete a Chunk the tail doesn't get automatically assigned to the previous.
    Anyone know how I can get around this retarded error? or what I can do to solve my problem?
    Edit: casting to Chunk<T> doesn't work either it's the same compiletime error
    I have deleted all irrelevant methods and comments from this: The error is in the deleteChunk() method. I need to point tail back to the previous node there.
    package chunklist;
    import java.util.AbstractCollection;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.NoSuchElementException;
    public class ChunkList<T> extends AbstractCollection<T>
        @SuppressWarnings({ "unchecked", "hiding" })
        private class Chunk<T>
            private T[] data;
            private Chunk<T> next;
            private int chunkSize;
            public Chunk()
                this.data = (T[])new Object[ARRAY_SIZE];
                this.next = null;
                this.chunkSize = 0;
            public boolean equalsChunk(Chunk<T> c)
                if (c == null)
                    return false;
                else if (this.chunkSize != c.chunkSize)
                    return false;
                else if (this.next != c.next)
                    return false;
                else
                    for(int i=0; i<this.chunkSize; ++i)
                        if (!(this.data.equals(c.data[i])))
    return false;
    return true;
    }// end of Chunk<T>
    @SuppressWarnings({ "hiding", "unchecked" })
    private class ChunkItr<T> implements Iterator<T>
    private Chunk<T> currentChunk;
    private Chunk<T> previousChunk;
    private Chunk<T> nextChunk;
    private int currentElement;
    public ChunkItr()
    currentChunk = (Chunk<T>) head;
    previousChunk = null;
    nextChunk = (Chunk<T>) head.next;
    currentElement = 0;
    @Override
    public boolean hasNext()
    if (currentChunk == null)
    return false;
    else
    if (currentElement < currentChunk.chunkSize)
    return true;
    return (currentChunk.next != null);
    @Override
    public T next()
    if (!hasNext())
    throw new NoSuchElementException();
    T elementToReturn = null;
    while (elementToReturn == null)
    if ((currentElement == ARRAY_SIZE) ||
    (currentElement == currentChunk.chunkSize))
    previousChunk = currentChunk;
    currentChunk = currentChunk.next;
    currentElement = 0;
    if (nextChunk != null)
    nextChunk = currentChunk.next;
    if (currentChunk.data[currentElement] != null)
    elementToReturn = (T) currentChunk.data[currentElement];
    ++currentElement;
    return elementToReturn;
    @Override
    public void remove()
    if (currentChunk == null)
    throw new IllegalStateException();
    else
    for (int i=currentElement-1;i<currentChunk.chunkSize;++i)
    { // shift everything down
    if ( (i != 7) && (i >= 0) )
    currentChunk.data[i] = currentChunk.data[i+1];
    else if (i==7)
    break;
    currentChunk.data[currentChunk.chunkSize-1] = null;
    --currentChunk.chunkSize;
    --numOfElements;
    --currentElement;
    if (currentElement < 0)
    currentElement = 0;
    if (currentChunk.chunkSize <= 0)
    deleteChunk();
    public void deleteChunk()
    if (previousChunk == null) //* @head *//
    if (head.next != null)
    head = head.next;
    currentChunk = (Chunk<T>) head;
    nextChunk = currentChunk.next;
    currentElement = 0;
    else currentElement=0;
    else if (nextChunk == null) //* @tail *//
    currentChunk = previousChunk;
    currentChunk.next = null;
    nextChunk = currentChunk.next;
    currentElement = currentChunk.chunkSize;
    tail = currentChunk; // THIS DOESN'T WORK, << ERROR HERE
    else //* @middle *//
    currentChunk = currentChunk.next;
    previousChunk.next = currentChunk;
    nextChunk = currentChunk.next;
    currentElement = 0;
    // back @ head? (just deleted Chunk before head)
    if (currentChunk.equalsChunk((Chunk<T>) head))
    previousChunk = null;
    } // end ChunkItr
    private static final int ARRAY_SIZE = 8;
    private Chunk<T> head;
    private Chunk<T> tail;
    private int numOfElements;
    public ChunkList()
    head = null;
    tail = null;
    numOfElements = 0;
    public void addNewChunk()
    if (head == null)
    head = new Chunk<T>();
    tail = head;
    else
    tail.next = new Chunk<T>();
    tail = tail.next;
    @Override
    public boolean add(T t)
    if (t == null)
    throw new IllegalArgumentException();
    if (head == null)
    addNewChunk();
    if (tail.chunkSize == ARRAY_SIZE)
    addNewChunk();
    tail.data[tail.chunkSize] = t;
    numOfElements++;
    tail.chunkSize++;
    return true;
    @Override
    public Iterator<T> iterator()
    return new ChunkItr<T>();
    @Override
    public boolean remove(Object o)
    // creates iterator and calls iterators remove method when it finds o.
    Edited by: G-Unit on Nov 14, 2010 5:07 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    YoungWinston wrote:
    Possibly, but I suspect you'll need to be prepared to defend your design choice with more than just test results. Why did you choose this pattern? Because it's an assignment. I will do some reading when I get around it to it. But for now I don't have time, and don't care to make time. This assignment was annoying as... So many fiddly little errors that took me too long to figure out. For now I hate Lists, I'm happy using the default ones.
    1. Introduction
    This document is the Project Specification for a ChunkList class to be developed by DBSD202 students this semester.
    2. What you must do
    The requirements specifications are detailed below:
    ChunkList
    In this first part of the assignment we will create a data structure called a ChunkList. The ChunkList class implements the Collection interface and >>serves a replacement for ArrayList or LinkedList. A ChunkList is like a regular linked list, except each node contains a little fixed size array of elements >>instead of just a single element. Each node also contains its own "size" int to know how full it is.
    The ChunkList will have the following features...
    The ChunkList object contains a head pointer to the first chunk, a tail pointer to the last chunk, and an int to track the logical size of the whole >>collection. When the size of the list is 0, the head and tail pointers are null.
    Each chunk contains a fixed size T[] array, an int to track how full the chunk is, and a next pointer. The constant ARRAY_SIZE = 8; in the chunk >>class defines the fixed size of the array. Elements should be added to the array starting at its 0 index. The elements in each little array should be >>kept in a contiguous block starting at 0 (this will require shifting elements around in the little array at times). (You may want to do some testing >>with ARRAY_SIZE set to smaller values, but turn it in set to 8.)
    ChunkList should be a subclass of AbstractCollection which provides some basic facilities built on top of your add(), iterator(), size() etc. primitives. >>Chunk should be an inner class defined inside of ChunkList. Only ChunkList will see or use the Chunk class directly. It's stylistically ok if ChunkList >>accesses the state (.next, .data, ...) of the Chunk objects, since Chunk essentially is just an integrated part of ChunkList. Add utility methods to >>Chunk where it helps to keep things receiver-
    relative (remove for example). ChunkIterator should be a private inner class as in the lecture example.
    ChunkList must support the messages: constructor, add(), size(), and iterator(). The iterator must support hasNext(), next(), and remove(). It's >>valid for the client to add "null" as an element, so you cannot use null as some sort of special marker in the array -- use your size int in each chuck. >>Make sure that size() and hasNext() are consistent about the size of the collection.
    The empty collection should be implemented as null head and tail pointers. Only allocate chunks when actually needed.
    The add() operation should add new elements at the end of the overall collection -- i.e. new elements should always go into the tail chunk. If the >>tail chunk is full, a new chunk should be added and become the new tail. We are not going to trouble ourselves shifting things around to use >>empty space in chunks in the middle of the list. We'll only look at the tail chunk.
    Do not use a dummy node because (a) it does not help the code much, and (b) dummy nodes are lame.
    Keep a single "size" variable for the whole list that stores the total number of client data elements stored in the list, so you can respond to size() in >>constant time. Similarly, keep a separate size in each chunk to know how full it is. Likewise, add(), hasNext(), next(), and remove() should all run in >>O(1) constant time (they may do computations proportional to ARRAY_SIZE, but not proportional to the overall collection length).
    When using iterator.remove() to remove an element from a Chunk, overwrite the pointer to that element with a null to help the garbage >>collector. This is not a requirement, but it's a nice touch.
    When an iterator.remove() operation causes a chunk to contain zero elements, that chunk should be removed from the list immediately. The code >>for deletion is quite tricky. You may store a "previous" pointer in each chunk if you wish. It is possible to code it without previous pointers by >>keeping extra pointers in the iterator to remember the two previously seen chunks during iteration. Chunk deletion will need to work for many >>boundary cases -- the first chunk, the last chunk, and so on. This is probably the trickiest part of the whole thing.
    When called with correct inputs, ChunkList should return the correct result. However, when called with incorrect inputs -- e.g. iterator.remove() >>without first calling next() -- ChunkList does not need to do anything in particular. It's fine if
    your code just gives the wrong output or throws a null pointer or other exception. This is a slight relaxation of the formal Collection interface which >>guarantees to throw particular exceptions for particular errors.
    ChunkList Advice — Tight Code
    The ChunkIterator is a tricky bit of code. There are about 4 different cases to get right, depending on if the removed chunk was first or last in the >>list. Don't have a separate copy of the remove code for each special case. If you find yourself copying and pasting code, you're doing it wrong. >>Clean up the solution so there is one copy of the remove code and then a few lines to deal with the special cases. This is just general coding style >>advice – avoid proliferating copies of the code for slightly different cases. Try to factor the code down so one copy of the code deals with many >>cases. The remove() method should be about 15 lines long.
    Testing
    The ChunkList is extremely well suited to unit-testing. This is good, since the ChunkList has such a large number of tricky little boundary cases >>where it can go awry. We will unit-test the ChunkList aggressively, since it's the best way to get the code right.
    1. ChunkList Basic Testing
    To get started, write some basic unit tests that build up a ChunkList of Strings with add(), and then iterate over it and remove a few elements, >>checking that the list look right before and after the removes. These tests will get the most basic add()/iterator()/remove() code working.
    2. ChunkList Super Test
    I will provide code for an extremely aggressive test on the ChunkList. Only try this after your basic tests are working. Because the ArrayList (known >>to be correct) and the ChunkList both implement the Collection interface, we can use a unit-test strategy where we do the same operation on >>both an ArrayList and ChunkList, and then verify that they get the same output after each operation.
    The SuperTest creates both an ArrayList and a ChunkList. We'll call an "operation" either a single addition or an iteration down the collection doing >>a few random removes. Do the same random operation to both the ArrayList and ChunkList, and then check that the two look the same, element >>by element. Then loop around and do that 4999 more times, checking the two again after each random operation. We want to push on the >>ChunkList
    to get every weird combination of list length and this or that chunk being full or empty at the time of add or series of removes in some position.
    When you get it take a look at the SuperTest code. It creates a Random(1) for its random number generation, object passing 1 as the seed. In >>this way, the series of "random" operations is the same every time the test is run.
    3. ChunkList SpeedTest
    The unit-tests should work on the correctness of the ChunkList, and that's the most important thing. Look at the source of the provided >>ChunkSpeed class and try running it. It runs a timing test on the ArrayList, LinkedList, and ChunkList classes. The test is a crude simulation of >>collection add/remove/iterate use. ChunkSpeed prints the milliseconds required to do the following representative mix of operations...
    - Use add() to build a 50,000 element collection
    - Create an iterator to iterate halfway through the collection
    - Use the iterator to remove 10,000 elements at that point
    - Creates and runs iterators to run over the whole collection 5 times
    The speeds seen depend on many factors, including the ARRAY_SIZE, the specific hardware, the system load, JVM version, etc., and some runs >>will be way off because the GC thread runs during part of the test. Broadly speaking, on average the ChunkList should be roughly as fast or faster >>than the LinkedList, and a lot faster (a factor of 10 or so) than the ArrayList. The speed numbers have a lot of noise in them, so don't worry about >>a single run. The ChunkList might be slower than the LinkedList on occasion. However, if your ChunkList is consistently slower than the Linked List >>or ArrayList, there is probably something wrong with your ChunkList algorithm -- some operation that is supposed to be O(1) is O(n). The most >>important methods to be fast are hasNext() and next(), since they are the most commonly called by the client.Edited by: G-Unit on Nov 15, 2010 7:31 AM
    Edited by: G-Unit on Nov 15, 2010 7:44 AM

  • Synchronized method's block list implementation

    In an object with synchronized methods, the OS maintains the list of blocked objects waiting to enter synchronzied methods. For this reason, I'm guesing, the Java spec seems to state the selection of these blocked objects as "arbitrary."
    I am trying to determine that there is no risk of stavation in this blocked pool of threads. For example, a FIFO implementation of the blocked-object list would guarantee that all objects eventually entered their appropriate synchronized method.
    Does anyone know for certain what blocked object selection algorithm is present on a JVM running on a Win32 platform? On SunOS 5.6? I believe the former uses a priority-based, preemptive thread scheduling with a round-robin-style time quantum to prevent starvation. Not sure what the latter uses.
    Any ideas? Thanks!
    -Jeff Ishaq

    In an object with synchronized methods, the OS
    maintains the list of blocked objects waiting to enter
    synchronzied methods. For this reason, I'm guesing,
    the Java spec seems to state the selection of these
    blocked objects as "arbitrary."
    As a general rule, you can never depend on the underlying threading model. The trend is to use the native threading model but that is not guaranteed by the specification.
    I am trying to determine that there is no risk of
    stavation in this blocked pool of threads. For
    example, a FIFO implementation of the blocked-object
    list would guarantee that all objects eventually
    entered their appropriate synchronized method.
    When a thread attempts to acquire a lock, it only checks to see if another thread already holds the lock, and not if another thread is already waiting for the lock. Therefore you should always consider the possibility that starvation can occur.
    Does anyone know for certain what blocked object
    selection algorithm is present on a JVM running on a
    Win32 platform? On SunOS 5.6? I believe the former
    uses a priority-based, preemptive thread scheduling
    with a round-robin-style time quantum to prevent
    starvation. Not sure what the latter uses.
    Again, you should avoid depending on the native threading model because the specification does not guarantee that the java threading model is going to behave the same way.
    To guarantee that each thread can acquire the lock you will need to develop a lock that has a queue associated with it. When a thread attempts to acquire the lock it is placed in a queue waiting until it is the first element in the queue. When the thread releases the lock it removes itself from the queue and notifies the other threads that are waiting.
    When using a queued lock you will not necessarily need to use the synchronized keyword on the method or block since the lock will take care of synchronization when a thread attempts to acquire the lock.

  • AJAX Select list implementation

    Hi,
    I'm trying to implement the AJAX Code Generator from Scott ( http://htmldb.oracle.com/pls/otn/f?p=33867:2 ) using dept no select list and dept name text field. When I change the Dept# selection from the options, all I get is a huge chunk of html code in my dept name text field and it doesn't contain the result.
    Can any one help me out with what i'm doing wrong?
    Thanks.
    - Richard

    Carl,
    Thanks for helping me out.
    Important thing I missed to mention in my original post.... I'm using HTMLDB ver 1.6 copied the js files needed, from htmldb.oracle.com
    Here is the url for the page I created in htmldb.oracle.com. But, when I recreated it, the onchange gets me "null" in department name field instead of huge chunk of HTML code.
    http://htmldb.oracle.com/pls/otn/f?p=19793:24:

  • Adjacency List implementation of a graph

    Hey everyone,
    I'm starting to code a directed graph using an adjacency list and I'm running into a little trouble. I understand the concepts of the adjacency list structure, but I cant write seem to figure out how to code one. So far I'm using two doubly linked lists for storing the vertices and edges, and each is in its own class (I thought this would come in handy when later coding traversals in the graph). In the graph class, I'm thinking that an array list would work to store the adjacent vertices (each value in the array storing a list of vertices which are adjacent). However, if this is right then I'm not sure what to do with the edges, and how to make each edge know which vertices it is connecting.. In general, I'm looking for comments/advice on this type of graph implementation. Anything will help. Thanks a lot.

    import java.util.*;
    public class AdjacencyListNode
        private Set<Node> successors = new HashSet<Node>();
        public void addSuccessor(Node n) { ... }
        public boolean predecessorOf(Node n) { ... }
    }Of course, if you want multiple edges between nodes or weighted edges then it'll need modifying. You may also want to be able to apply a visitor to the successors.

  • List Implementation

    I have an application in which different kinds of messages are sent to the User..i.e.
    I have a base abstract MESSAGE class , with certain attributes and abstract methods.
    Now I have sub classes : MESSAGE1 , MESSAGE2 ...so on, with each class having differnt attributes
    Now I have a MessageBean class. This class has to store the different kinds of Messages.
    It will store an ArrayList of Message1 , Message2 and so on (ArrayList - Since every user can have several Message1 kind of messages to be sent)
    In the MessageBean class I have a method to formatMessage(). This function takes each Message ArrayList (defined as aattributes of the MessageBean class) and iterates over each object and format the message.
    This is how I have designed it.
    the ugliness in my lies in having to iterate over each MessageList one after another in the formatMessage() method.
    I was thinking on the lines of having a MessageList class itself, which will iterate over the messages.
    I need suggestions to know what is a suitable design
    public class MessageBean {
         ArrayList Message1List, Message2List, Message3List, Message4List, Message5List;
         public void addMessage1(){
              if(Message1List == null)
                   Message1List = new ArrayList();                    
         public void addMessage1(Collection messages){
              if(Message1List == null)
                   Message1List = new ArrayList();
              Message1List.addAll(messages);
         public void addMessage2(Collection messages){
              if(Message2List == null)
                   Message2List = new ArrayList();
              Message2List.addAll(messages);
         public void formatAllMessages(){
              Iterator messageItr = null;
              StringBuffer sb = new StringBuffer();
              if(Message1List != null
                        && Message1List.size() > 0){
                   messageItr = Message1List.iterator();
                   Message1 m1 = null;
                   sb.append("This is Message 1");
                   while(messageItr.hasNext()){
                        m1 = (Message1)messageItr.next();
                        m1.format();
                   sb.append("This is End of Message 1");
              if(Message2List != null
                        && Message2List.size() > 0){
                   messageItr = Message2List.iterator();
                   Message2 m2 = null;
                   sb.append("This is Message 2");
                   while(messageItr.hasNext()){
                        m2 = (Message1)messageItr.next();
                        m2.format();
                   sb.append("This is End of Message 2");
              so.on..for each Message List.
    }

    Designs support the business model. A design that is appropriate for one business model is inappropriate for another.
    If it was me, given only the requirements you mentioned, I would generate all of the code.
    If there are additional requirements then a metadata model might be better. That would give only one object and would store the different attributes in that object as a hash.

  • What can be the error in this simple Linked List Implementation

    i have a linked list code that wont compile successfully. The code is
    //Lets try the Linked List 
    import java.util.*;
    class LinkedListDemo {
    public static void main ( String args[]){
         LinkedList l1=new LinkedList();
         l1.add( "A");
         l1.add(2);
         l1.add(3);
         l1.add(4);
         l1.add(5);
         l1.addFirst(6);
         l1.add(7);
         l1.add(8);
         l1.add(9);
         //Lets check what does the Linked List hold at this time
         System.out.println("Prsently the linked lis is having:  "+l1);
    }Problem is with the add method . Compiler error is that it doesnt recognize the symbol ie add method.

    i m sorry , java version is 1.4In that case, read up on the link jverd posted on AutoBoxing. You can only add Objects to a List. An int is a primitive, not an Object. You can try something like this:
    l1.add(new Integer(2));

  • JSF List implementation

    I have one managed bean A which has as it's member variables ArrayList B, ArrayList C, and ArrayList D. I have methods within the managed bean A that performs operations on the three separate lists. Say for instance, whenever I want to reference the size of any of the lists from a view, I have methods within A that return the size.
    I am assuming with JSF that this type of behavior can be defined some way in the faces_config.xml without actually having to define the lists and their types within the managed bean itself, but I haven't quite figured out how. I am assuming that you would define a managed bean for B, C, and D, and having A defined with lists with those types repsectively, but I'm at a loss as how. Any ideas?

    Firstably what does this have to do with Java Studio Enterprise? This question is more suited for JSF forum. Anyway...
    There is nothing magical about JSF and in my view it is just another way to put together servlets, JSP, taglibs and JavaBeans. In other words it does not do anything the others cannot do. You still have to load the bean using the classloader and then refer to it from the JSP page. Where you specify what bean to load, when and how is the question for the JSF forum though.
    Regards jP

  • Linked List implementation

    I am working on a ListNode and I need to provide implementation for a garbageCollection() method.
    What the method needs to do is
    // recalculate start address for each node in alloclist
    // delete all but the first node in freelist,
    // update start address and size of this single free block
    Any ideas of how I can do this.

    I am working on a ListNode and I need to provide
    implementation for a garbageCollection() method. You're probably in a class discussing memory allocation. It's quite easy actually but it requires some insight. Good luck -:)

  • T-List implementation

    I am having a problem getting my t-list to populate with values from a database table. I have a table that has one column of data that I wish to display in a t-list. The elements in the column will change so I want to populate the t-list dynamically. The book "Oracle Developer Advanced Forms & Reports" has a recipe for doing so but the preparation step does not detail what the procedure called f_item.setup_list should contain nor where it needs to be called from.
    Thanks!

    For T-list, you need to create a Record Group.
    Step 1.
    Create a record group say the record group's name is'record_grp'..type in the query..
    Select col1, col2
    FROM schema.table
    Where...
    Step 2
    If col1 and col2 is not varchar2, double click on the record group item, click 'Column Specifications', change both col1 and col2 to varchar2 (THOSE HAVE TO BE VARCHAR2,OTHERWISE, IT WILL NOT WORK)
    NOTE: col1 is for label which is display on list item, col2 is the value of that list item.
    step 3.
    You need to use the folling built-ins for your trigger (e.g. When-New-Form-Instance)
    In the trigger..put the folling codes
    -- first populate the group
    IF Populate_Group('grp_name') = 0 THEN
    Populate_List('list_name','grp_name');
    END IF;
    Hope it helps you.

  • How  to Implement a Chained Hash Table with Linked Lists

    I'm making a migration from C/C++ to Java, and my task is to implement a Chained Hash Table with a Linked List. My problem is to put the strings(in this case names) hashed by the table using de Division Metod (H(k)= k mod N) in to a Linked list that is handling the colisions. My table has an interface implemented(public boolean insert(), public boolean findItem(), public void remove()). Any Help is needed. Thanks for everyone in advance.

    OK. you have your hash table. What you want it to do is keep key/value pairs in linked lists, so that when there is a collision, you add the key/value pair to the linked list rather than searching for free space on the table.
    This means that whenever you add an item, you hash it out, check to see if there is already a linked list and if not, create one and put it in that slot. Then in either case you add the key/value pair to the linked list if the key is not already on the linked list. If it is there you have to decide whether your requirements are to give an error or allow duplicate keys or just keep or modify one or the other (old/new).
    When you are searching for a key, you hash it out once again and check to see if there is a linked list at that slot. If there is one, look for the key and if it's there, return it and if not, or if there was no linked list at that slot, return an error.
    You aren't clear on whether you can simply use the provided linked-list implementations in the Java Collections or whether you have to cobble the linked list yourself. In any case, it's up to you.
    Is this what you're asking?
    Doug

  • Help needed in linked lists...

    I have been working on this computer assignment lately but I still don't understand linked lists yet..I did an assignment on array based implementation and now I am supposed to do the same thing in linked list implementation..
    I need help on how to change this into a linked list implementation..any help would be appreciated. Thank you..below is the code for the array based implementation..the only thing that needs change here is after where is says Array-based implementation of the ADT list.
    public class ListArrayBasedDriver {
      public static void main(String [] args) {
        ListArrayBased myGroceryList = new ListArrayBased();
        myGroceryList.add(1,"milk");
        myGroceryList.add(2,"eggs");
        myGroceryList.add(3,"butter");
        myGroceryList.add(4,"pecans");
        myGroceryList.add(5,"apples");
        myGroceryList.add(6,"bread");
        myGroceryList.add(7,"chicken");
        myGroceryList.add(8,"rice");
        myGroceryList.add(9,"red beans");
        myGroceryList.add(10,"sausage");
        myGroceryList.add(11,"flour");
        printList(myGroceryList); //print out original List
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
        System.out.println("adding juice for 5th item...");
        myGroceryList.add (5, (Object) "juice");  //add juice
        System.out.println("item 5 is: " + myGroceryList.get(5)); //get position 5
        printList(myGroceryList);
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
        System.out.println("removing juice...");
        myGroceryList.remove (5); //remove item at position 5
        printList(myGroceryList);
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
      public static void printList(ListArrayBased myList)
            //method prints a list, numbering the values,  e.g, "1.  milk" .... "5.  juice".... etc.
            int i;
            for(i=1; i <= myList.size(); i++)
                String tempString = new String((String)myList.get(i));
                System.out.println(i+" "+ tempString);
    // Array-based implementation of the ADT list.
    class ListArrayBased {
        private static final int MAX_LIST = 50;
        private Object items[];  // an array of list items
        private int numItems;  // number of items in list
        public ListArrayBased()
        // creates an empty list
             items = new Object[MAX_LIST];
             numItems = 0;
        }  // end default constructor
        public boolean isEmpty()
          return (numItems == 0);
        } // end isEmpty
        public int size()
           return numItems;
        }  // end size
        public void removeAll()
          // Creates a new array; marks old array for
          // garbage collection.
          items = new Object[MAX_LIST];
          numItems = 0;
        } // end removeAll
        public void add(int index, Object item) throws  ListIndexOutOfBoundsException
          if (numItems > MAX_LIST)
            throw new ListException("ListException on add");
        }  // end if
          if (index >= 1 && index <= numItems+1)
            // make room for new element by shifting all items at
            // positions >= index toward the end of the
            // list (no shift if index == numItems+1)
            for (int pos = numItems; pos >= index; pos--) {
              items[translate(pos+1)] = items[translate(pos)];
          } // end for
          // insert new item
          items[translate(index)] = item;
          numItems++;
          else
          {  // index out of range
            throw new ListIndexOutOfBoundsException(
             "ListIndexOutOfBoundsException on add");
          }  // end if
        } //end add
        public Object get(int index) throws ListIndexOutOfBoundsException
          if (index >= 1 && index <= numItems)
            return items[translate(index)];
          else 
          {  // index out of range
            throw new ListIndexOutOfBoundsException(
              "ListIndexOutOfBoundsException on get");
          }  // end if
        } // end get
        public void remove(int index) throws ListIndexOutOfBoundsException
          if (index >= 1 && index <= numItems)
            // delete item by shifting all items at
            // positions > index toward the beginning of the list
            // (no shift if index == size)
                for (int pos = index+1; pos <= size(); pos++) {
                    items[translate(pos-1)] = items[translate(pos)];
          }  // end for
          numItems--;    
          else
          {  // index out of range
            throw new ListIndexOutOfBoundsException("ListIndexOutOfBoundsException on remove");
          }  // end if
        } // end remove
        private int translate(int position) {
        return position - 1;
       } // end translate
    }  // end ListArrayBased
    class ListException extends RuntimeException
      public ListException(String s)
        super(s);
      }  // end constructor
    }  // end ListException
    class ListIndexOutOfBoundsException
                extends IndexOutOfBoundsException {
      public ListIndexOutOfBoundsException(String s) {
        super(s);
      }  // end constructor
    }  // end ListIndexOutOfBoundsException

    Could someone check for me if this will work and if it doesn't what I need to do to make it work..Thanks...
    public class ListArrayBasedDriver {
      public static void main(String [] args) {
        ListArrayBased myGroceryList = new ListArrayBased();
        myGroceryList.add(1,"milk");
        myGroceryList.add(2,"eggs");
        myGroceryList.add(3,"butter");
        myGroceryList.add(4,"pecans");
        myGroceryList.add(5,"apples");
        myGroceryList.add(6,"bread");
        myGroceryList.add(7,"chicken");
        myGroceryList.add(8,"rice");
        myGroceryList.add(9,"red beans");
        myGroceryList.add(10,"sausage");
        myGroceryList.add(11,"flour");
        printList(myGroceryList); //print out original List
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
        System.out.println("adding juice for 5th item...");
        myGroceryList.add (5, (Object) "juice");  //add juice
        System.out.println("item 5 is: " + myGroceryList.get(5)); //get position 5
        printList(myGroceryList);
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
        System.out.println("removing juice...");
        myGroceryList.remove (5); //remove item at position 5
        printList(myGroceryList);
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
      public static void printList(ListArrayBased myList)
            //method prints a list, numbering the values,  e.g, "1.  milk" .... "5.  juice".... etc.
            int i;
            for(i=1; i <= myList.size(); i++)
                String tempString = new String((String)myList.get(i));
                System.out.println(i+" "+ tempString);
    // Linked List-based implementation of the ADT list.
    class ListNode
         //class to represent one node in a list
         class ListNode
              //package access members; List can access these directly
              Object data;
              ListNode nextNode;
              //contructor creates a ListNode that refers to object
              ListNode( Object object)
                   this( object, null );
              } //end ListNode one-argument constructor
              //constructor creates ListNode that refers to
              // Object and to the next ListNode
              ListNode ( Object object, ListNode node)
                   data = object;
                   nextNode = node;
              // end ListNode two-argument contructor
              //return reference to data in node
              Object getObject()
                   return data; // return Object in this mode
              //return reference to next node in list
              ListNode getNext()
                   return nextNode; // get next node
              } // end method getNext
    } //end class ListNode
    //class List Definition
    public class List
         private ListNode firstNode;
         private ListNode lastNode;
         private String name; // string like " list " used in printing
         //contructor creates empty List with " list " as the name
         public List()
              this(" list ");
         } //end List no-arguement constructor
    //contructor creates an empty list with a name
    public List( String listName )
         name = listname;
         firstNode = lastNode = null;
    } //end List no-arguement contructor
    //insert Object at front of List
    public void insertAtFront ( object insertItem )
         if ( isEmpty() ) //firstNode and lastNode refer to same object
              firstNode = lastNode = newListNode( insertItem );
         else // firstNode refers to new node
              firstNode = new ListNode ( insertItem, firstNode );
    } // end method insertAtFront
    // insert Object at end of List
    public void insert AtBack ( Object insertItem )
         if ( isEmpty() ) //firstNode and lastNode refer to same object
              firstNode = new ListNode ( insertItem );
         else // firstNode refers to new node
         firstNode = new ListNode (insertItem, firstNode );
    } // end method insertAtFront
    // insert Object at end of List
    public void insertAtBack ( Object insertItem )
         if ( isEmpty() ) //firstNode and LastNode refer to same Object
              firstNode = lastNode = new ListNode ( insertItem );
         else // lastNode = lastNode.nextNode = new ListNode ( insertItem );
    } // end method insertAtBack
    //remove first node from List
    public Object removeFromFront() throws EmptyListException
         if( isEmpty() ) //throw exception if list is empty
         throw new EmptyListException( name );
         object removedItem = firstNode.data; //retrieve data being removed
    // update references firstNode and lastNode
    if (firstNode == lastNode )
         firstNode =lastNode = null;
    else
         firstNode = firstNode.nextNode;
         return removedItem; // return removed node data
    } //end method removeFromFront
    //remove last node from List
    Public Object removeFromBack() throws EmptyListException
         If ( isEmpty() ) // throw exception if list is empty
              throw new EmptyListException( name );
         Object removedItem = lastNode.data; // retrieve data being removed
         // update references firstNode and lastNode
         If ( firstNode == lastNode )
              firstNode = lastNode = null;
         else // locate new last node
              ListNode current = firstNode;
              // loop while current node does not refer to lastNode
              while ( current.nextNode != lastNode )
                   current = current.nextNode;
              lastNode = current; // current is new lastNode
              current.nextNode = null;
         } // end else
         return removedItem; // return removed node data
    } // end method removeFromBack
    // determine whether list is empty
    public boolean isEmpty()
         return firstNode == null; // return true if list is empty
    }     // end method isEmpty
    //output List contents
    public void print()
         if (isEmpty() )
              System.out.printf(�Empty %s\n�, name );
              return;
         System.out.printf(�The %s is: �, name );
         ListNode current = firstNode;
         //while (current != null )
              System.out,printf(�%s �, current.data );
              current = current.nextNode;
         } //end while
         System.out.println( �\n� );
    } //end method print
    } end class List

  • Question about ASE 15.7 kernel mode – process vs threaded

    Hi there,
    This question is related to upgrading Sybase ASE Server
    from version 15.5 to version 15.7 on Sun Solaris SPARC Operating System
    (Solaris 10). For the upgrade, I need to choose between threaded kernel and
    process kernel mode.
    1> Is the process kernel mode in ASE 15.7 identical to
    process kernel in ASE 15.5? Are there any changes to process kernel mode
    between version 15.5 and 15.7? With all the other configurations on the Solaris
    host being same (Number of CPUs, RAM, Storage, Sybase ASE Configuration
    parameter values like total memory, engines), will the performance on ASE 15.7
    in process kernel mode be same as on ASE 15.5?
    If there are differences in performance, what are they? What should I be monitoring on ASE 15.7 to see
    if there is performance issue on the ASE Server?
    2> For the threaded kernel mode, are there any performance
    overheads like more CPU usage? We are not planning to change the hardware
    configuration of the Solaris host during the upgrade.  What values should I be monitoring at the OS
    level OR Sybase ASE level to make sure that there are no performance issues? Is
    there any particular parameter that needs to be monitored closely when we
    change to threaded kernel mode?
    Are there any Sybase Configuration parameters that I need
    to tune for the New threaded kernel mode? If so, do you have any performance
    tuning tips (white papers, technical documents) for threaded kernel mode?
    3> What is SAP Sybase recommendation on which Kernel mode I
    should be using? I researched the SAP Knowledge Base articles for
    recommendations on which Kernel mode to use and I could not find a definitive answer.
    Thanks,
    Raj

    Actually with Solaris on SPARC, there is a very key consideration - you should be on ASE 15.7 sp50 or sp100 or higher AND have applied the kernel jumbo patch (Oracle BugID 16054425) from Solaris that fixes the issue in which they prohibited OS threads from issuing KAIO calls.   Then in ASE, you need to configure the 'solaris async i/o mode' parameter.
    The changes between threaded and process mode kernels should be transparent to your application.  Generally speaking, SAP recommends 'threaded' kernel mode - and specifically for SAP applications only certifies 'threaded' kernel mode.    For custom applications, you *could* use either - although, depending on how many engines you run and what chipset you are on, you might see better performance with one vs. the other - typically threaded kernel mode is better, although there are exceptions.
    Generally, the main difference is that in process kernel mode, each engine did disk and network IO polling.   Due to OS security restrictions, this often meant that a engine had to process the disk IO in which it submitted...or for networking, your SPID had to run on your network engine for any network IO.  In threaded mode, there is a single parent process with engine tasks (threads) and IO tasks (threads).   Consequently, for customers used to running in the 10's of engines, we suggest a starting point of reducing the number of engines by 2 to give the IO tasks CPU time.
    One reason why threaded mode is often better is due to OS scheduling.   With hardware threaded cores, most OS dispatch schedulers do a better job of spreading the threads across the cores before utilizing the threads when a process is multi-threaded with POSIX threads - then a multi-process/kernel threaded implementation.   At one customer, we proved that we consistently got the best performance with threaded kernel and the only way we could match it with process kernel was to use OS cpu affinity to bind the ASE engine processes to individual cores.
    However, one consideration is that older SPARC Niagara chips (T1-T4) were notoriously bad at network handling for some reason.   As a result, one of the recommendations for ASE on SPARC Niagara chips is to run the same number of network engines as the number of cores ASE is using.   One solution to that is in Solaris 11 (I think) where Solaris finally started being able to handle network interrupts better - I also think the T5/T6 are much better chips - but I have no customer experience data to go on there.

  • Comparable linked list sorting

    i have been trying to find a way to sort a link listed. After some reading i found out that it is probably best to use collections.sort(list). I think i understand how to implement it , i need to declare a compareto and equals method. However, most of the reading i have done shows how to create a collection from a linked list and add items to the collection and sort them, however it doesn show how to copy this sorted collection back inot a linked list. I need to remove items and add items to the sorted linked list. Is it possible to create a linked list, sort it using the collection sort and return the sorted linked list? I have looked in the api's but got confused!!

    You don't need to copy anything.
    List list = new LinkedList(); // or ArrayList
    // list.add stuff
    Collections.sort(list); Assuming whatever you added to the list implements Comarable, the list is now sorted.

Maybe you are looking for

  • Gmail push not working since upgrading to 4.0

    I have not been able to get my email to push since upgrading to 4.0. I have a 3GS and it worked great until the upgrade. Still have it set to push. Tried deleting itunes completely and then restore of iphone. Still no go. Please help.

  • About making a down payment using F-51(without posting through F-48)

    Hi Friends, There are situations where the client has to make a down payment against a P.O. (even before the invoice is recieved). Then the normal process is to make a down payment using F-48 with a spl. GL indicator, in this process if there is TDS

  • Net Price List Report V_NL- SDNETPRO

    Dear  SAP Friends, I trying to use standard V_NL net price list report, the number are not matching up to the subtotals values in pricing procedure. While calculating manually it is found that the condition records whichever has scales involved is gi

  • [SOLVED] Search in a file

    Hi! I'm working on a radio script with several functions, but i need your help to continue.  I want to search for a spefic string in a file. The files content is like: Super Hot Girls Radio Channel;http://lovepotion.org:666 Sir Camelot Danish Radio;k

  • File sharing across multiple computers - is there an easier way?

    Have a small office that is getting bigger, so we purchased a new 20" iMac. Previously, we had an old iMac G4 and iBook G4. All three computers are part of the same LAN. In the past, we have shared files across the computers by first mounting a share