Vector contains and Integer

Hello
So far I tried to use a Vector to store different integers. I wrap them in an Integer object and add them to the Vector.
Since the user can select (from a JTree) multiple nodes and even the same node by clicking it again, I have to check if the ID is already stored in the Vector. But my implementation does not work - the contains method seems not to work for me. I guess I have a wrong understanding.
What happens is that if I click let's say on Node X with the ID of 5, the ID get's stored, but if I click on any other node contains returns true and the already stored node gets removed.
I'd be glad for any advise. This is the snippet:
            category_id = category.getCategory_id();           
            module_id = category.getModule_id();
            create = category.getCREAT();
            Integer categoryInt = new Integer(category_id);
            System.out.println("Value changed: "+category_id);
            if(categories.contains(categoryInt))
                 categories.remove(categoryInt);
            else
                 categories.add(categoryInt);Thank you. Regards
Tarik

Hi,
your snippet works. I have tried it and it does what
you expect. There must be something wrong in the
surrounding code. You already added that
System.out.println. Doesn't give this more
information?Thank you very much for the reply. I tested it with the System.out. but even though there were 3 dirfferent nodes selected the Vector always had a size of 1. I've replaced the Vector with a Hash Set and it worked that way.
But anyway thank you it's good that this question mark is cleared, so I do not have to discriminate Vector's :-) It must have been something else that was causing that problem.
Tarik.

Similar Messages

  • Vector.contains()

    Hi,
    I have a question about Vector.contains(). The documentation for Vector.contains() says:
    Tests if the specified object is a component in this vector.
    Returns true if and only if the specified object is the same as a component in this vector, as determined by the equals method; false otherwise.
    Since Vector.contains() takes an Object as a parameter and Object.equals() takes and Object has a parameter I assumed that Vector.contains(a) would return true if at least one object in the Vector returned true for .equals(a). But it seems to me (after some pretty simple testing) that the two objects HAVE to be of the same class, yet it does not actually say this in the documentation.
    Can someone explain to me why this is the case, or tell me that I am somehow doing somthing wrong? I dont have somple simple test code but I dont want to post it here intitiall as I might scare people off :p. I spend hours debugging this simple problem.. grr :S.
    Anyway,
    Thanks in advance.

    Thanks for your quick replies!!
    Do you not think this is a given? How is it possible for two objects to be the same if they are different classes?I'm not saying that its not logical, its just that the documentation doest actually specify that the classes have to be of the same type to be found. You might, for example, want to search a list of 'Person' objects for a person with a particular name. In this case (where a is defined as Vector<Person>), you might want to call a.contains("Barry"). Based on the documentation I would have thought this to be possible, as long as the Person.equals() function handled it correctly.
    Here is my test code:
    import java.util.*;
    public class Test
            static class MyClass
                    String myValue;
                    public MyClass(String val)
                            myValue = val;
                    public boolean equals(Object o)
                            return o.toString().equals(myValue);
                    public String toString()
                            return myValue;
            public static void main(String[] args)
                    Vector<MyClass> v = new Vector<MyClass>();
                    v.add(new MyClass("TEST1"));
                    v.add(new MyClass("TEST2"));
                    if (v.contains("TEST2"))
                            System.out.println("Contains!");
                    else
                            System.out.println("Does not contain!");
    }In this case "Does not contain!" could be printed out. If i change the line
    if (v.contains("TEST2"))to
    if (v.contains(new MyClass("TEST2")))then "Contains!" is printed out. I would have thought both should work :S.
    Thanks again
    - Robert.

  • Vectors: contains() inconsistency with Object equals()

    Hi,
    I have a problem with using Vector contains() on my own classes.
    I have a class TermDetails, on which I have overloaded the equals() method:
         public boolean equals(Object other) {
              try {
                   TermDetails otherTerm = (TermDetails) other;
                   return (term.equals(otherTerm.term));
              catch (Exception e) {
                   try {
                        String otherTermString = (String) other;
                        return (term.equals(otherTermString));
                   catch (Exception f) {
                        System.out.println("Can't convert Object to TermDetails or String");
                        System.out.println(f.getMessage());
                        return(false);
         public boolean equals(String otherTermString) {
              return(term.equals(otherTermString));
    The Vector.contains() should then use one of these equals methods to return correctly, but doesn't use either of them... any ideas why not?
    (I've tried adding some console output in the equals methods, just to prove if they get called or not. They don't.)
    Thanks in advance!
    Ed

    This won't work. It only tests whether the two objects are of the same class. In general, you need to test a number of things:
    1) if obj == this, return true
    2) if obj == null, return false
    3) if obj.getClass() != this.getClass() return false
    (Note: You don't need getClass().getName(). Also, there are times when the classes don't have to match, but it's sufficient that obj and this implement a particular interface--Map for instance).
    4) if all relevant corresponding fields of obj and this are equal, return true, else false.
    That's just a high level run-down, and you should definitely look at the book that schapel mentioned.
    Also, this probably won't affect Vector.contains, but make sure that when you override equals, you also override hashCode. The rule is that if a.equals(b) returns true, then a.hashCode() must return the same value as b.hashCode(). Basically any field that is used in computing hashCode must also be used in equals.
    Note that the converse is not true. That is two objects with the same hashCode don't have to be equal.
    For instance, if you've got a class that represents contact info, the hashCode could use only the phoneNumber field. hashCode will then be fast to compute, will probably have a good distribution (some distinct people's contact info could have the same phone number, but there won't be a large overlap), and then you use phone number plus the rest of the fields (address, etc.) for equals.
    Here's an example that shows that equals will work if
    written correctly
    import java.util.Vector;
    public class testEquals {
    public static void main(String args[]) {
    Vector testVector = new Vector();
    testVector.add(new A());
    testVector.add(new B());
    System.out.println("A == A? " +
    + testVector.contains(new A()));
    System.out.println("B == B? " +
    + testVector.contains(new B()));
    class A {
    public boolean equals(Object object) {
    if (getClass().getName() ==
    = object.getClass().getName()) {
    System.out.println("A == A");
    return true;
    } else {
    return false;
    class B {
    public boolean equals(Object object) {
    if (getClass().getName() ==
    = object.getClass().getName()) {
    System.out.println("B == B");
    return true;
    } else {
    return false;

  • Do Vectors search and remove in log(n) time?

    Hi,
    I'm working on an application using a Vector to store a sorted list of numbers. Since it's sorted, it would be advantageous to use a log(n) algorithm for searching and removing items. So I'm wondering if the Vector.contains(Object) and Vector.remove(Object) methods know to search for items in a divide-and-conquer manner when it's sorted. I'd use these methods if this is so. Otherwise, I'm wondering if it would make my program run faster if I were to create my own contains(Object) and remove(Object) methods for searching and removing. Does anyone know what kind of algorithms the Vector class uses for these tasks?
    Gib

    Both Vector and ArrayList use an array as an underlying store.
    Thus a remove results in all the subsequent objects being moved up one.
    From the 1.4.2 source for Vector
        public boolean remove(Object o) {
            return removeElement(o);
        public synchronized boolean removeElement(Object obj) {
         modCount++;
         int i = indexOf(obj);
         if (i >= 0) {
             removeElementAt(i);
             return true;
         return false;
        public int indexOf(Object elem) {
         return indexOf(elem, 0);
        public synchronized int indexOf(Object elem, int index) {
         if (elem == null) {
             for (int i = index ; i < elementCount ; i++)
              if (elementData==null)
              return i;
         } else {
         for (int i = index ; i < elementCount ; i++)
              if (elem.equals(elementData[i]))
              return i;
         return -1;
    public synchronized void removeElementAt(int index) {
         modCount++;
         if (index >= elementCount) {
         throw new ArrayIndexOutOfBoundsException(index + " >= " +
                                  elementCount);
         else if (index < 0) {
         throw new ArrayIndexOutOfBoundsException(index);
         int j = elementCount - index - 1;
         if (j > 0) {
         System.arraycopy(elementData, index + 1, elementData, index, j);
         elementCount--;
         elementData[elementCount] = null; /* to let gc do its work */
    There is a call to arraycopy to move all the Object down one.

  • How to refresh the data in a container and to update the new data

    Hi,
    I have created a Module Pool Program in which i have two containers to display the long text.
    Initially this container is filled and based on some condition i want to update the text in the same conatiner.
    I am using the below two classes to do all this.
    cl_gui_textedit,
    cl_gui_custom_container,
    Could someone help me how to remove the long text in the container and update the new long text.
    I am getting the new long text but not able display it in the same container. Please someone help me how to refresh and update the container.
    Thanks in advance.

    Hi
    Try this.
      IF cl_gui_textedit  IS INITIAL.
      create control container
        CREATE OBJECT cl_gui_custom_container
           EXPORTING
                container_name = 'Container Name''
           EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
    create text_edit control
        CREATE OBJECT cl_gui_textedit
           EXPORTING
                parent = cl_gui_custom_container
                wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
                wordwrap_to_linebreak_mode = cl_gui_textedit=>false
           EXCEPTIONS
                error_cntl_create      = 1
                error_cntl_init        = 2
                error_cntl_link        = 3
                error_dp_create        = 4
                gui_type_not_supported = 5.
      ENDIF.
    *--use method to set the text
      CALL METHOD cl_text_edit->set_text_as_stream
        EXPORTING
          text            =  t_lines ( Internal table with long text).
        EXCEPTIONS
          error_dp        = 1
          error_dp_create = 2
          OTHERS          = 3.
    regards,
    Raghu.

  • Hey, How do I populate my replace colors color library in illustrator? I tried to replace color on a traced/ vectorized image and when I selected and went to the color library CC said I need to use a valid username. I was already logged into my adobe acco

    Hey, How do I populate my replace colors color library in illustrator? I tried to replace color on a traced/ vectorized image and when I selected and went to the color library CC said I need to use a valid username. I was already logged into my adobe account.

    Can you please show a screenshot of what exactly you want to replace where?

  • Chart Error - scroller positions should be positive and integer

    <p>
    Hello Expert
    I have created a flash chart with two filters on the chart region.
    i) &lsquo;Select list with submit' ----- (:P23_TRC)
    ii) &lsquo;Radio button with submit' -----(:P23_IMPACTC)
    The chart should display as per the filters selection.
    However, I get the error message "<strong>scroller positions should be positive and integer</strong>", once, whenever I load this chart page for the 1st time in a new IE window.
    After I change the filter's value it will work perfectly fine.
    In filters default value is one value from respective filter list of value
    </p>
    <p>
    If I remove the filter conditions from chart query, it works perfectly without error.
    <u>Here are my chart series queries</u>
    select null link, V.LOB label, COUNT(TR) "Customer Care"
    from V_PROCESSTRACKING V
    Where V.ProcessArea like '%Customer Care%' and (V.TR = :P23_TRC) AND ((V.IMPACT = :P23_IMPACTC)OR (:P23_IMPACTC = 'ALL'))
    group by V.LOB
    order by V.LOB
    select null link, V.LOB label, COUNT(TR) "Sales"
    from V_PROCESSTRACKING V
    Where V.ProcessArea like '%Sales%' and (V.TR = :P23_TRC) AND ((V.IMPACT = :P23_IMPACTC)OR (:P23_IMPACTC = 'ALL'))
    group by V.LOB
    order by V.LOB
    <u>Customer XML</u>
    &lt;?xml version = "1.0" encoding="utf-8" standalone = "yes"?&gt;
    &lt;root&gt;
    &lt;type&gt;
    &lt;chart type="Stacked Horizontal 3DColumn"&gt;
    &lt;animation enabled="yes" appearance="size" speed="10" /&gt;
    &lt;hints auto_size="yes"&gt;
    &lt;text&gt;&lt;![CDATA[{NAME}, {VALUE}]]&gt;&lt;/text&gt;
    &lt;font type="Verdana" size="10" color="0x000000" /&gt;
    &lt;/hints&gt;
    &lt;names show="no"/&gt;
    &lt;values show="no" prefix="" postfix="" decimal_separator="." thousand_separator="," decimal_places="0" /&gt;
    &lt;arguments show="no" /&gt;
    &lt;column_chart column_space="3" block_space="12"&gt;
    &lt;border enabled="no" /&gt;
    &lt;block_names enabled="yes" placement="chart" position="left" &gt;
    &lt;font type="Verdana" size="10" color="0x000000" /&gt;
    &lt;/block_names&gt;
    &lt;/column_chart&gt;
    &lt;/chart&gt;
    &lt;workspace&gt;
    &lt;background enabled="yes" type="solid" color="0xffffff" alpha="0" /&gt;
    &lt;base_area enabled="no" /&gt;
    &lt;chart_area enabled="yes" x="215" y="50" width="705" height="500" deep="0"&gt;
    &lt;background enabled="no"/&gt;
    &lt;border enabled="yes" size="1"/&gt;
    &lt;/chart_area&gt;
    &lt;x_axis name="Line of Business" smart="yes" direction="horizontal" rotation="-90" position="left_center" &gt;
    &lt;font type="verdana_embed_tf" size="14" color="0x000099" bold="yes" align="center" /&gt;
    &lt;/x_axis&gt;
    &lt;y_axis name="No. of Process" smart="yes" position="center_bottom" &gt;
    &lt;font type="Verdana" size="14" color="0x000099" bold="yes" align="center" /&gt;
    &lt;/y_axis&gt;
    &lt;grid&gt;
    &lt;values /&gt;
    &lt;/grid&gt;
    &lt;/workspace&gt;
    &lt;legend enabled="yes" x="935" y="50"&gt;
    &lt;names enabled="yes"&gt;
    &lt;font type="Verdana" size="9" color="0x000000" bold="yes"/&gt;
    &lt;/names&gt;
    &lt;values enabled="no"/&gt;
    &lt;scroller enabled="no"/&gt;
    &lt;header enabled="no"/&gt;
    &lt;background alpha="0"/&gt;
    &lt;/legend&gt;
    &lt;/type&gt;
    #DATA#
    &lt;/root&gt;
    <strong>Help please!!!!! It's urgent</strong>
    Sagar
    </p>

    Hi Rima,
    I found the solution,
    My graph is dependent on the page items. What I found was when I load the page, item default value was displayed but it was not stored in the memory. Item value only gets stored in memory when the page is submitted.
    Line: -----
    Soultion : - Create a page level before header process and define the default value over here as well. This will resolve your error.
    Hopefully you understood what I am trying to explain. If not let me know and I will trying to put in picture and email you.
    Sagar

  • Why am I getting the error message "Can't open the illustration. The illustration contains and incomplete or garbled object description."

    I work in a graphic design firm and 4 separate people have received these messages on separate days using separate files on separate MAC computers. We are all using CS6.
    "Can't open the illustration. Could not complete the requested operation."
    "Can't open the illustration. The illustration contains an illegal operand. 1206.3.6006 % 1205.9736 1178.52 m % 1206.2236 1178.8374 I % 1206.3232 1178.% 1206.3.6006"
    "Can't open the illustration. The illustration contains an illegal or misplaced operator. ∘ê 3 0 R 508054 0 R 508055 0 R]/Order 508056 0 R/RBGroups[]>>/OCGs[5 0 R 6 0 R 7 0 R 8 0 R 9 0 R 46702 0 R 46703 0 R 46704 0 R 467"
    "Can't open the illustration. The illustration contains and incomplete or garbled object description."
    After clicking ok the file will open; however, most of the illustration is missing. We are interested in repairing our files, but we are more interesting in figuring out why this is happening and fixing it. We are nervous to even open anything for fear this will happen again.
    Please help!

    brittanyesparks,
    One thing often tried first is to create a new document and File>Place the corrupted one to see how much may be rescued that way (remember to tick Paste remembers Layers in the Layer palette flyout/dropdown first, and to untick it afterwards).
    Here is a website where you can see whether it can rescue the file, and if it can, you may pay for a subscription to have it done,
    http://www.recoverytoolbox.com/buy_illustrator.html
    and another similar website,
    http://markzware.com/adobe-software/fix-illustrator-file-unknown-error-occurred-pdf2dtp-fi le-recovery/
    As far as I remember, the former is for Win and the latter for Mac.
    Here are a few pages about struggling with it yourself:
    http://daxxter.wordpress.com/2009/04/16/how-to-recover-a-corrupted-illustrator-ai-file/
    http://helpx.adobe.com/illustrator/kb/troubleshoot-damaged-illustrator-files.html
    http://kb2.adobe.com/cps/500/cpsid_50032.html
    http://kb2.adobe.com/cps/500/cpsid_50031.html
    http://helpx.adobe.com/illustrator/kb/enable-content-recovery-mode-illustrator.html

  • Main Wrapper, Container and background-image repeat problem-and Footer :-)

    Hi everyone,
    First off, i tried almost every idea i could get to solve this on my own but now im...aaa...
    Well, the problem is i have a main wrapper with a background image repeat. A header,menu, body container - which has a left column and right column. I want that main wrapper,body container and both of the columns to grow auto according to content. I tried the height:100%. When i float the columns the text from left column spills over on to the footer. The left column also does not autogrow towards the footer?! I was able to set the footer at the bottom which i want it to remain at the bottom of the main wrapper, but the main wrapper and the columns do not grow automatically...I guess it has something to do with float and the clear properties but what???
    body{
    margin: 0;
    padding: 0;
    font-weight: normal;
    font-style: normal;
    font-size: 11px;
    font-family: verdana;
    text-align: center;
    background:url(back_index3.png) repeat-x scroll 0 0 #E4E4E4;
    #main_wrapper {
    width: 959px;
    margin:0 auto;
    margin-top:80px;
    background:url(backslice.png) repeat-y;
    height:auto;
    min-height:800px;
    #header {
    width: 959px;
    margin-left: auto;
    margin-right: auto;
    height:119px;
    background:red;
    padding-top: 0px;
    padding-bottom: 0px;
    #topmenu {
    background-color:#blue;
    height:30px;
    margin:0px;
    width: 959px;
    margin-left: auto;
    margin-right: auto;
    #body_container {
    height:100%;
    width: 949px;
    margin: 0 auto;
    #content {
    float:left;
    width: 645px;
    background:yellow;
    border-right:1px solid #ffffff;
    padding:10px;
    height:100%;
    text-align:left;
    #sidebar {
    float:left;
    width: 283px;
    background:#234234;
    height:100%;
    #footer {
    clear:both;
    height:200px;
    background-color: #686768;
    margin:0 auto;
    border-top: 1px solid #F6F6F6;
    text-align:center;
    width: 100%;
    <html xmlns="">
    <head>
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="3css.css" />
    <meta http-equiv="content-type" content="text/html" />
    </head>
    <body>
    <div id="main_wrapper">
         <div id="header">
          <span id="header_logo">title</span>
         </div>
         <div id="topmenu">
         menu
         </div>
         <div id="body_container">
          <div id="content">
    content to be added
          </div>
          <div id="sidebar">
          hallow2
          </div>
         </div>
    </div>
    <div id="footer">
    asd
    </div>
    </body>
    </html>
    Thanks in advance if somebody can help me out here.
    you can see an image of the problem in the attachement down thr... thnx

    <html xmlns="">
    <head>
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="3css.css" />
    <meta http-equiv="content-type" content="text/html" />
    </head>
    <body>
    <div id="main_wrapper">
         <div id="header">
          <span id="header_logo">title</span>
         </div>
         <div id="topmenu">
         menu
         </div>
         <div id="body_container">
          <div id="content">
    content to be added
          </div>
          <div id="sidebar">
          hallow2
          </div>
         </div>
    </div>
    <br clear="all" />
    <div id="footer">
    asd
    </div>
    </body>
    </html>
    Hope this will work well

  • Docking container and SAP standard transaction

    Hello,
    in one screen I have a tree control container and a docking container. With the tree control container everything is perfect. If the user does a click on a node on the tree in the docking container there should be shown a SAP standard transaction (QA03) with the corresponding data.
    I have not found a possibility to show QA03 or QM03 in a docking container. I also tried it in a splitter container, but I do not know how.
    Can anybody help me?
    Greetings
    Corinna

    Hello Corinna
    There is a simple answer to your question: it is not possible.
    Container can only hold other containers or controls.
    Do not be fooled by the ABAP workbench where we apparently can switch between different transactions (e.g. display a class [SE24], show method coding [SE80], double-click on a DDIC structure [SE11]). The ABAP workbench simply changes the control to be displayed but NOT the transaction (remains always the same).
    Regards
      Uwe

  • Is there a way to combine "contains" and "Startswith"? Or a better way???

    I have a script that looks for reserved words in a list of words.  It works but it's slow and I think there has got to be a better and faster way.  I was thinking of how to combine the use of the -contains and $string.StartsWith but haven't had
    any luck.
    Here's what I have.  Any help would be appreciated.
    function ProcessStartsWith ($word)
        $flag = $false
        if ($word.StartsWith("con.")) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("con,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("prn."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("prn,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("nul."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("nul,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("aux."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("aux,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com0."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com0,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com1."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com1,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com2."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com2,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com3."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com3,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com4."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com4,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com5."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com5,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com6."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com6,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com7."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com7,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com8."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com8,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com9."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("com9,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt0."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt0,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt1."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt1,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt2."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt2,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt3."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt3,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt4."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt4,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt5."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt5,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt6."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt6,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt7."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt7,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt8."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt8,"))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt9."))) { $flag = $true }
        if ((!$flag) -and ($word.StartsWith("lpt9,"))) { $flag = $true }
        return $flag
    function ProcessWords($words)
        $errorcount = 0
        foreach ($word in $words)
            if (($ReservedWords -contains $word) -or (ProcessStartsWith($word)))
                "ReservedWord--- = " + $word
                $errorcount = $errorcount + 1
        return $errorcount
    $ReservedWords = "prn","nul","con","aux"
    $ReservedWords = $Reservedwords + "com0","com1","com2","com3","com4","com5","com6","com7","com8","com9"
    $ReservedWords = $Reservedwords + "lpt0","lpt1","lpt2","lpt3","lpt4","lpt5","lpt6","lpt7","lpt8","lpt9"
    $wordlist = "prn", "prnOK", "con", "control", "com0", "com0.", "com0otion"
    ProcessWords($wordlist)
    Running this results with this output
    ReservedWord--- = prn
    ReservedWord--- = con
    ReservedWord--- = com0
    ReservedWord--- = com0.
    4

    I don't know what the fastest way of accomplishing this would be, but you can certainly make it a lot shorter with a regular expression. For example, this code produces the same output:
    $reservedPattern = '^(?:prn|nul|con|aux|com\d|lpt\d)(?:[\.,]|$)'
    $wordlist = "prn", "prnOK", "con", "control", "com0", "com0.", "com0otion"
    $matchesReserved = $wordlist -match $reservedPattern
    foreach ($word in $matchesReserved)
    "ReservedWord--- = $word"
    $matchesReserved.Count

  • [BUG]PS CC Layer Group add vector mask and disable it,use path selection tool click,always crash!!!

    [Bug] Photoshop CC,Layer Group add vector mask and disable it, use path selection tool click canvas, always crash!!!  Please help me!
    The sample psd file(158KB):
    http://doc.aoyea.com/ps_cc_bug.psd
    My Computer configuration:
    SONY VAIO CA100 Notebook、Intel Core I5 2410 CPU、16GB RAM、AMD Radeon 6600M(1G RAM)、Windows7 x64 SP1(clean)、Scratch disk free space is 100GB
    email: [email protected]

    Hi,
    As far as i know that's a bug that will hopefully be fixed in the next update to photoshop cc.

  • How to turn logo into crisp clean vector black and white outline?

    I have the colored logo in vector but I need a crisp clean vector black and white outline.
    Please advise.
    Thank you!

    You might be able to at least color all the dark parts in black via Edit > Edit colors > Recolor art.
    Maybe you can use it as well to color all the other parts in white (depends on how many there are and if it doesn't get too cluttered).
    You might also try to use the magic wand tool to select stuff and then apply different colors.

  • Container and codec for images

    hello guys
    my question is
    has images container and codec like videos?
    can you give m some example of images container and codec?
    another question
    png, jpeg, gif etc are codec or container?
    i have a lot of confusion in my head U_U

    Well, if one wants to get highly technical, those Still Images do contain CODEC's, or sorts. Most are compressed formats, and Encoding was required to write them. Then, one does Decode the information via the file's header, but with Stills, it differs from Video (and most Audio), in that the information to Decode is constant, and is not anywhere near as variable, as with Video. For instance, if one does not have the capability to Decode JPEG2000 (usually via a plug-in), they cannot Open one on that system. Same with writing the file - if they do not have the JPEG2000 capability, that option will not be listed. So yes, one could extend the term CODEC to cover the Still Image formats, but that is an uncommon application of the term CODEC. Here, it really gets down to semantics and common usage.
    For Audio, which is not muxed, things are still pretty simple. WAV (the format), will most likely have PCM, or LPCM (similar, but with some differences), and the file will be Uncompressed. MP3, will only have the MPEG, with certain, limited parameters. AC3 (a form of MPEG), can have some variations, but the most common is the Dolby Digital MPEG CODEC, and is often referred to as DD AC3. That can be a 2-channel (most often seen as stereo, but not always), or 6-channel (most often seen as 5.1 SS, but not always).
    When one muxes the Audio & Video Streams into one "wrapper," or format, things can get a bit more involved, though the Audion Stream is usually much more limited.
    Some Video CODEC's can appear in different wrappers, but when the standards are broken, many programs can experience issues, as they are hard-coded to look for a particular set of Video CODEC's, in particular formats. Recently, some camera mfgrs. have decided to wrap the H.264 CODEC into an AVI wrapper. Programs, like Premiere Pro are not used to looking for H.264 in the AVI wrapper. It looks for H.264 in MOV, MTS, MP4, and a few more, wrappers.
    Then, one gets to AVCHD, with IS a sub-set of H.264, but all H.264 material is NOT AVCHD. It is particular.
    To confuse things, even more, some camera mfgrs. have gone back to an older CODEC, MJPEG (Motion JPEG), but have tweaked that for their specific uses. That means that one might have an MJPEG CODEC installed on the system, but it will not work in their editng program, as camera mfgr. ____ tweaked the CODEC, that they use. In that case, it is best to install the camera mfgr's. specific version of MJPEG.
    Keeping 100% current on Video CODEC's is an impossible task, as new ones, or tweaked versions of older ones, are introduced about every six mos, and some of those are NOT placed into the common wrappers. Knowing the general concepts, and a few of the most common Video CODEC's, is as good as it gets.
    Hope that helps,
    Hunt

  • Container and package

    How should I compare container and package in Java?
    Are they meaning the same thing?
    Thanks,

    Package is a classification system for classes.
    Container is generally a class, system of classes or system that can stores references to other classes of a specific type, obviously with the intention of managing that 'contained' class.
    I don't believe the two are in anyway related.
    PD.

Maybe you are looking for