Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
Q

quartaela

@quartaela
About
Posts
34
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • using a private variable for the lock of synchronized block
    Q quartaela

    hi there i am trying to implement a simple chatserver and when searching for examples i saw a synchronized statement which uses a variable as a lock of the block.. the code is this;

    private List myList = new ArrayList();
    private Map();

    public void put( String s, Bar b ) {
    synchronized( myMap ) {
    myMap.put( s,b );
    // then some thing that may take a while like a database access or RPC or notifying listeners
    }
    }

    public void hasKey( String s, ) {
    synchronized( myMap ) {
    myMap.hasKey( s );
    }
    }

    public void add( Foo f ) {
    synchronized( myList ) {
    myList.add( f );
    // then some thing that may take a while like a database access or RPC or notifying listeners
    }
    }

    public Thing getMedianFoo() {
    Foo med = null;
    synchronized( myList ) {
    Collections.sort(myList);
    med = myList.get(myList.size()/2);
    }
    return med;
    }

    so i cant understand why and how can be a list be a lock. i always use "this" for accessing a synchronized statement. i appreciated if you can help me and thanks anyway : )

    Java database algorithms help

  • creating a class with coding_?.
    Q quartaela

    well i will have a search on these links. thanks mate : )

    Java java visual-studio help tutorial question

  • creating a class with coding_?.
    Q quartaela

    yess i mean this. well i am taking java courses and i want some java homework so he told me that i can work on this subject.: ) finally i created the code and it creates the files which must be compiled. so only the problem is how can i compile them : )

    Java java visual-studio help tutorial question

  • creating a class with coding_?.
    Q quartaela

    yess i mean this. well i am taking java courses and i want some java homework so he told me that i can work on this subject.: )

    Java java visual-studio help tutorial question

  • creating a class with coding_?.
    Q quartaela

    well ok you are right : ). i will delete the topic .

    Java java visual-studio help tutorial question

  • are there any functions in java like ispunct, isspace in C_?
    Q quartaela

    hey sorry for late answer : ). nope this is not a business requirement only a little work. so i mean you can not use "!+^%.." characters in name. for exmaple "Pe&%ter".

    Java java question

  • creating a class with coding_?.
    Q quartaela

    hi there i am working on a project that my goal is when i run my code it will create another file(classes) (exp: personalList.java) and user must associate with second file. for example; i have a file "PersonalDatabaseCreator.java" and this file creates "Person.java" (which is my object and includes properties getters setters etc.) and "PersonalList.java" which user will interact. (PersonalList.java ask the location of the text file which contains people to add into a LinkedList. Therefore, user will do add search remove etc. operations). but the problem it only works when i create classes in IDE myself and copying the code into them and run them. so i need a code which will do it itself!. you will say i am working on a silly project : D. but i wonder if is there any code samples like this_?. and i hope i explained my problem correctly. so thanks anyway : ).

    Java java visual-studio help tutorial question

  • are there any functions in java like ispunct, isspace in C_?
    Q quartaela

    thanks mate i will try it then : )

    Java java question

  • are there any functions in java like ispunct, isspace in C_?
    Q quartaela

    well yes i know this class but i guess there arent any specific functions which they check specific characters. as you see in the link http://cplusplus.com/reference/clibrary/cctype/ there are several functions. but in java i can't check a string contains only alphabetic characters_?

    Java java question

  • are there any functions in java like ispunct, isspace in C_?
    Q quartaela

    hi there i am trying write a function that checks if a string contains punctuation characters like %,&,!. because i dont want to user enter an invalid name last_name so i want check the string.

    Java java question

  • find diffrence between current time and birthday as a number of days.
    Q quartaela

    and also i guess this is for C#_?. :).

    C / C++ / MFC tutorial help

  • find diffrence between current time and birthday as a number of days.
    Q quartaela

    well mate i guess this is C++ or C#_? cause i can't understand the codes. i am working with C :). but thanks for your help

    C / C++ / MFC tutorial help

  • find diffrence between current time and birthday as a number of days.
    Q quartaela

    well finally i managed it :). thanks for your help mates :).

    C / C++ / MFC tutorial help

  • find diffrence between current time and birthday as a number of days.
    Q quartaela

    well i almost near the solution. i use atoi() (i can't use strtoi() cause i guess compiler or O/S doesn't compatible with this function). so this the example code

    int main(void) {

    char c\[11\] = "2000/10/15";
    
           printf("the number is %d", atoi(c));
    return 0;
    

    }

    and the output is 2000. the problem is how can i take other numbers "10" and "15". i guess when i take this numbers i can able to solve the problem.

    C / C++ / MFC tutorial help

  • find diffrence between current time and birthday as a number of days.
    Q quartaela

    well i search all the fields of time.h in the link which you gave me but i can't find any solutions. i guess i will use difftime to compare two dates which are time_t variables. but the problem is i read the birthday string from the file and need to convert this string to time_h variable and then i can compare current time and her/his birthday. i will search another ways.

    C / C++ / MFC tutorial help

  • find diffrence between current time and birthday as a number of days.
    Q quartaela

    but if i give size of 20 to string "buff" how can i manage to make unused fields to 0. and i only read the strings with "YYYY-MM-DD" from a file not including minutes and second etc._?

    C / C++ / MFC tutorial help

  • find diffrence between current time and birthday as a number of days.
    Q quartaela

    well yes you are right :). on the other hand this is C++. i forgot to say that i am working with C.

    C / C++ / MFC tutorial help

  • find diffrence between current time and birthday as a number of days.
    Q quartaela

    hi friends i am trying to find the contacts who have a birthday in the next 7 days in my list. i managed get the current time as a string but i am stucked here. i know i must compare only number of the month and day. so use subtraction and if the result is <=7 i will show the contact. but i don't know how to do this. i appreciated if you can help me. and here is the my example code.

    #include <stdio.h>
    #include <time.h>
    #include <string.h>

    int main( )
    {
    char buff[11];
    char birth[11]="2011-05-15";

    int res;
    
    time\_t now = time(NULL);
    strftime(buff, 20, "%Y-%m-%d\\n", localtime(&now));
    
             
             res = difftime(mktime(birth), now);
    	  
    	  printf("%d", res);
    	  
    	 return 0;
    

    }

    C / C++ / MFC tutorial help

  • about multi linked list
    Q quartaela

    i don't understand the operation you said "mark the item in the ordered list as dead - you can't delete it or you'll ruin the indices". how can i do this_?. i am using free(nameofptr) function to delete the node_?.

    C / C++ / MFC help com data-structures performance tutorial

  • about multi linked list
    Q quartaela

    well mate i guess i will do with your suggested way. one ADD and Remove function. hope i can do it in time. and for your last suggestion it is perfect!! but i have corner cases. :)

    C / C++ / MFC help com data-structures performance tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups