Search Results

Search found 342 results on 14 pages for 'xor linkedlist'.

Page 2/14 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C# XOR on two byte variables will not compile without a cast

    - by Ash
    Why does the following raise a compile time error: 'Cannot implicitly convert type 'int' to 'byte': byte a = 25; byte b = 60; byte c = a ^ b; This would make sense if I were using an arithmentic operator because the result of a + b could be larger than can be stored in a single byte. However applying this to the XOR operator is pointless. XOR here it a bitwise operation that can never overflow a byte. using a cast around both operands works: byte c = (byte)(a ^ b);

    Read the article

  • Problem with xor operation

    - by gavishna
    Kindly tell me why the original image is not coming with this code. The resulting image receive is yellowish in color,instead of being similar to the image Img_new Img=imread(‘lena_color.tif’); Img_new=rgb2gray(img); Send=zeroes(size(Img_new); Receive= zeroes(size(Img_new); Mask= rand(size(Img_new); for i=1 :256 for j=1:256 Send(i,j)=xor( Img_new(i,j),mask(i,j)); End End image(send); imshow(send); for i=1 :256 for j=1:256 receive(i,j)=xor( send(i,j),mask(i,j)); End End image(receive); imshow(receive); plz help

    Read the article

  • Help with abstract class in Java with private variable of type List<E>

    - by Nazgulled
    Hi, It's been two years since I last coded something in Java so my coding skills are bit rusty. I need to save data (an user profile) in different data structures, ArrayList and LinkedList, and they both come from List. I want to avoid code duplication where I can and I also want to follow good Java practices. For that, I'm trying to create an abstract class where the private variables will be of type List<E> and then create 2 sub-classes depending on the type of variable. Thing is, I don't know if I'm doing this correctly, you can take a look at my code: Class: DBList import java.util.List; public abstract class DBList { private List<UserProfile> listName; private List<UserProfile> listSSN; public List<UserProfile> getListName() { return this.listName; } public List<UserProfile> getListSSN() { return this.listSSN; } public void setListName(List<UserProfile> listName) { this.listName = listName; } public void setListSSN(List<UserProfile> listSSN) { this.listSSN = listSSN; } } Class: DBListArray import java.util.ArrayList; public class DBListArray extends DBList { public DBListArray() { super.setListName(new ArrayList<UserProfile>()); super.setListSSN(new ArrayList<UserProfile>()); } public DBListArray(ArrayList<UserProfile> listName, ArrayList<UserProfile> listSSN) { super.setListName(listName); super.setListSSN(listSSN); } public DBListArray(DBListArray dbListArray) { super.setListName(dbListArray.getListName()); super.setListSSN(dbListArray.getListSSN()); } } Class: DBListLinked import java.util.LinkedList; public class DBListLinked extends DBList { public DBListLinked() { super.setListName(new LinkedList<UserProfile>()); super.setListSSN(new LinkedList<UserProfile>()); } public DBListLinked(LinkedList<UserProfile> listName, LinkedList<UserProfile> listSSN) { super.setListName(listName); super.setListSSN(listSSN); } public DBListLinked(DBListLinked dbListLinked) { super.setListName(dbListLinked.getListName()); super.setListSSN(dbListLinked.getListSSN()); } } 1) Does any of this make any sense? What am I doing wrong? Do you have any recommendations? 2) It would make more sense for me to have the constructors in DBList and calling them (with super()) in the subclasses but I can't do that because I can't initialize a variable with new List<E>(). 3) I was thought to do deep copies whenever possible and for that I always override the clone() method of my classes and code it accordingly. But those classes never had any lists, sets or maps on them, they only had strings, ints, floats. How do I do deep copies in this situation?

    Read the article

  • Copy a LinkedList that has a Random Pointer in it

    - by Bragaadeesh
    Hi, First of all this is not a homework, this is an interview question that I got from a company I attended today. You have a singly linked list with the Node structure as the following class Node{ int data; Node next; Node random; } You have a typical singly linked list of length n. The random pointer in each node in the linkedlist randomly points to some Node within the linked list. The Question is to create a copy of the linked list efficiently into a different LinkedList. I said that I will first calculate the Random pointer's position in the linked list and store it in an array. Then create a new linked list normally. Then iterate through the linked list by setting the random pointer where they belong by reading the values stored from the array. I know its a very brute force technique and the interviewer asked me to come up with a better solution but I couldnt. Please can someone answer this? I can explain if the question is not clear.

    Read the article

  • Being a more attractive job candidate - Certs XOR Degree

    - by Zephyr Pellerin
    I'm currently working in an IT position, where I do helpdesk stuff, and predominantly security related issues/consulting (In the loosest sense of the term) In-House and for Service-Contract clients (as the only/acting CCSP [I guess I should say only person with Cisco experience] in my organization). I've professionally written Kernel Mode drivers for a gaming company. Among other things that I'm proud to put on a resume. I think of myself as very reasonably qualified as a System Administrator, With excellent Cisco experience, among other things I think would make a good addition to almost any IT staff in need of a new employee. However, Something has always tripped me up - Human Resources. Let me explain, I decided to skip the university route - I'm immensely glad that I did, The computer science graduates that I've met and work with rarely know much of anything about Computers (Until they gain some 'real' experience), Even when asked about Theoretical Computing fundamentals they can rattle something off about Turing Completeness but rarely do they understand the mathematical underpinnings. In short, I think instead of going to college, I'd rather pick up some real world experience. However, Apparently, Employers rarely think the same way. A quick perusal of jobs through the standard job search engine yields nothing short of a conspiracy to exclude anyone without 'A Bachelors Degree in Computer Science or Equivalent'. Interviews I've had in the past have almost always been entangled with - 1. My Age (Which I can't really change) and 2. Lack of Degree. Employers frequently disregard the CCNA/CCSP, The experience I've gained through internships, My extensive experience in x86 assembly and C, among so many other things I like to think are valuable to employers - In lieu of the fact that I don't have a piece of paper. So, AS AN EMPLOYER - Is it even worth working on my CCIE? Or should I pad my resume with certifications that are easier to acquire (Like CISSP, MSCE, Network+, etc.). Or should I ditch the whole idea and head back to get a Mathematics or CS degree?

    Read the article

  • Why does my C++ LinkedList cause a EXC_BAD_ACCESS?

    - by Anthony Glyadchenko
    When I call the cmremoveNode method in my LinkedList from outside code, I get an EXC_BAD_ACCESS. /* * LinkedList.h * Lab 6 * * Created by Anthony Glyadchenko on 3/22/10. * Copyright 2010 __MyCompanyName__. All rights reserved. * */ #include <stdio.h> #include <iostream> #include <fstream> #include <iomanip> using namespace std; class ctNode { friend class ctlinkList ; // friend class allowed to access private data private: string sfileWord ; // used to allocate and store input word int iwordCnt ; // number of word occurrances ctNode* ctpnext ; // point of Type Node, points to next link list element }; class ctlinkList { private: ctNode* ctphead ; // initialized by constructor public: ctlinkList () { ctphead = NULL ; } ctNode* gethead () { return ctphead ; } string cminsertNode (string svalue) { ctNode* ctptmpHead = ctphead ; if ( ctphead == NULL ) { // allocate new and set head ctptmpHead = ctphead = new ctNode ; ctphead -> ctpnext = NULL ; ctphead -> sfileWord = svalue ; } else { //find last ctnode do { if ( ctptmpHead -> ctpnext != NULL ) ctptmpHead = ctptmpHead -> ctpnext ; } while ( ctptmpHead -> ctpnext != NULL ) ; // fall thru found last node ctptmpHead -> ctpnext = new ctNode ; ctptmpHead = ctptmpHead -> ctpnext ; ctptmpHead -> ctpnext = NULL ; ctptmpHead -> sfileWord = svalue ; } return ctptmpHead -> sfileWord ; } string cmreturnNode (string svalue) { return NULL; } string cmremoveNode (string svalue) { if (ctphead == NULL) return NULL; ctNode *tmpHead = ctphead; while (tmpHead->sfileWord != svalue || tmpHead->ctpnext != NULL){ tmpHead = tmpHead->ctpnext; } if (tmpHead == NULL){ return NULL; } else { while (tmpHead != NULL){ tmpHead = tmpHead->ctpnext; } } return tmpHead->sfileWord; } string cmlistList () { string tempList; ctNode *tmpHead = ctphead; if (ctphead == NULL){ return NULL; } else{ while (tmpHead != NULL){ cout << tmpHead->sfileWord << " "; tempList += tmpHead->sfileWord; tmpHead = tmpHead -> ctpnext; } } return tempList; } }; Why is this happening?

    Read the article

  • LinkedList parameters in Java

    - by Walt
    Hi there, I created a program that contains linked lists that are passed various methods. While this works just fine in Java... a style checker program we have to use doesn't like it It says: Declaring variables, return values or parameters of type 'LinkedList' is not allowed. If I declare them as simply List then I don't have access to the methods I want. What should I do?

    Read the article

  • Java - PriorityQueue vs sorted LinkedList

    - by msr
    Hello, Which implementation is less "heavy": PriorityQueue or a sorted LinkedList (using a Comparator)? I want to have all the items sorted. The insertion will be very frequent and ocasionally I will have to run all the list to make some operations. Thank you!

    Read the article

  • When to use LinkedList<> over ArrayList<>?

    - by sdellysse
    I've always been one to simply use List<String> names = new ArrayList<String>(); I use the interface as the type name for portability, so that when I ask questions such as these I can rework my code. When should LinkedList should be used over ArrayList and vice-versa?

    Read the article

  • C++ and,or,not,xor keywords [closed]

    - by uray
    Possible Duplicate: The written versions of the logical operators. I notice that C++ define keyword and, or, not, xor, and_eq, or_eq, not_eq and xor_eq as an alternative to &&, ||, !, ^, &=, |=, != and |=. and they're rarely used! What's wrong? Are they not portable?

    Read the article

  • LinkedList insert tied to inserted object

    - by wrongusername
    I have code that looks like this: public class Polynomial { List<Term> term = new LinkedList<Term>(); and it seems that whenever I do something like term.add(anotherTerm), with anotherTerm being... another Term object, it seems anotherTerm is referencing the same thing as what I've just inserted into term so that whenever I try to change anotherTerm, term.get(2) (let's say) get's changed too. How can I prevent this from happening?

    Read the article

  • LinkedList.contains execution speed

    - by Le_Coeur
    Why Methode LinkedList.contains() runs quickly than such implementation: for (String s : list) if (s.equals(element)) return true; return false; I don't see great difference between this to implementations(i consider that search objects aren't nulls), same iterator and equals operation

    Read the article

  • Java: Swap elements in LinkedList class

    - by Algorist
    Hi, I want to maintain order of the elements being added in a list. So, I used a linkedlist in Java. Now I want to be able to swap two elements in the linked list. First of all, I cannot find an elementAt method for linked list. Also, there is no way to add element at a specified position. Thank you.

    Read the article

  • LinkedList cannot be serialised?

    - by iTayb
    Here are my classes: http://pastebin.com/3dc5Vb1t When I try to run BookStore b = new BookStore(); b.LoadFromXML(Server.MapPath("list.xml")); Label1.Text = b.ToString(); I get the following error: You must implement a default accessor on System.Collections.Generic.LinkedList`1[[Book, App_Code.cxsacizw, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] because it inherits from ICollection. The error source is XmlSerializer s = new XmlSerializer(typeof(BookStore)); When I tried to look for a solution on google, I found it that LinkedList has some problems with serialization. How can I deal with it? Thank you very much.

    Read the article

  • WithEvents LinkedList is it Impossible?

    - by serhio
    What is the optimal approach to a WithEvents Collection - VB.NET? Have you any remarks on the code bellow (skipping the Nothing verifications)? The problem is when I obtain the LinkedListNode(Of Foo) in a For Each block I can set myNode.Value = something, and here is a handlers leak... -Could I override the FooCollection's GetEnumerator in this case? -No. :( cause NotInheritable Class LinkedListNode(Of T) Class Foo Public Event SelectedChanged As EventHandler End Class Class FooCollection Inherits LinkedList(Of Foo) Public Event SelectedChanged As EventHandler Protected Overloads Sub AddFirst(ByVal item As Foo) AddHandler item.SelectedChanged, AddressOf OnSelectedChanged MyBase.AddFirst(item) End Sub Protected Overloads Sub AddLast(ByVal item As Foo) AddHandler item.SelectedChanged, AddressOf OnSelectedChanged MyBase.AddLast(item) End Sub ' ------------------- ' Protected Overloads Sub RemoveFirst() RemoveHandler MyBase.First.Value.SelectedChanged, _ AddressOf OnSelectedChanged MyBase.RemoveFirst() End Sub Protected Overloads Sub RemoveLast(ByVal item As Foo) RemoveHandler MyBase.Last.Value.SelectedChanged, _ AddressOf OnSelectedChanged MyBase.RemoveLast() End Sub ' ------------------- ' Protected Sub OnSelectedChanged(ByVal sender As Object, ByVal e As EventArgs) RaiseEvent SelectedChanged(sender, e) End Sub End Class

    Read the article

  • Logical xor operator in c++?

    - by RAC
    Is there such a thing? First time I encountered a practical need for it, but I don't see one listed in stroustrup. I intend to write: // Detect when exactly one of A,B is equal to five. return (A==5) ^^ (B==5); But there is no ^^ operator. Can I use bitwise ^ here and get the right answer (regardless of machine representation of true and false)? I never mix & and &&, or | and ||, so I hesitate to do that with ^ and ^^. I'd be more comfortable writing my own "bool XOR(bool,bool)" function instead.

    Read the article

  • Java LinkedList iterator being exhausted prematurely

    - by Sujeet
    I am using LinkedList and retrieving an Iterator object by using list.iterator(). After that, I am checking it.hasNext(), real issue is while checking it.hasNext(), sometimes it returns false. I need help why this is happening, though I have elements in the list. Some code: public synchronized void check(Object obj) throws Exception { Iterator itr = list.iterator(); while(itr.hasNext()) { //This Line I get false.. though i have list size is 1 Item p = (Item)itr.next(); if(p.getId() == null) {continue;} if(p.getId().getElemntId() == obj.getId() || obj.getId() == 0 ) { p.setResponse(obj); notifyAll(); return; } } Log.Error("validate failed obj.getId="+obj.getId()+" **list.size="+list.size()*This shows 1*); throw new Exception("InvalidData"); }

    Read the article

  • jquery-sortable using behavior of a linkedlist

    - by BabaBooey
    I suspect I'm not looking at this issue in the right way so here goes. I have essentially a LinkedList of data on a web page (http://en.wikipedia.org/wiki/Linked_list) that I'd like to manipulate using traditional Linked List behavior (i.e. just updating the reference/id of the "next" object) for performance reasons. Where this gets a bit tricky is I'd ideally like to use Jquery's sortable to do this. Like the user would drag something up/down and I could just do an Ajax call to the server with the id of the object that moved and the new parent id of that object (and then behind the scenes I could figure out how to reconnect things..maybe need more data than that...). But every example I've seen where sortable is used they were sending the whole re-indexed list to the database to update which seems unnecessary to me. With a linked list to change an element's "index" I only need to make 3 updates which depending on the size of the list could be a big performance savings. Anyone have an example of what I'm trying to do...am I too far in left field?

    Read the article

  • How to use a linkedList and multiple classes with my Java GUI

    - by Asj
    How should I use a linked list with my GUI program? The program is supposed to have blocks with textareas and dropdown menus. The number of blocks depends on the number of times the user presses a button. It's supposed to be possible to put blocks within blocks. I want to store the information created, using a linked list and then saving to a file. I'm thinking, for the sub blocks, there would be linked lists within the linked list. Should I use Java.util.LinkedList? How do I add the information? A Node class? Should that be in a separate file? I started to try sitting up a linked list, but it's getting me confused. I'm still unsure about how a person is supposed to make GUI's. I've only seen really simple GUI's. Can anyone tell me how I should arrange things? At the moment, I have three files, one for the main GUI window, one for the question blocks to be inserted within that, and one for some tools to use within those two files to make the code easier to understand. But, there seems to be something wrong with the question block file, because I've been making the background white for each JPanel, and there's a gray outline around the question blocks when I run the program. I probably shouldn't paste a ton of code here... These are my files: http://asj127.webs.com/BuildAssessmentWindow.java http://asj127.webs.com/QuestionBlock.java http://asj127.webs.com/JPanelTools.java

    Read the article

  • error in C# code

    - by user318068
    hi all . I have a problem with my code in C# . if i click in compiler button , I get the following errors 'System.Collections.Generic.LinkedList' does not contain a definition for 'removeFirst' and no extension method 'removeFirst' accepting a first argument of type 'System.Collections.Generic.LinkedList' could be found (are you missing a using directive or an assembly reference?). and 'System.Collections.Generic.LinkedList' does not contain a definition for 'addLast' and no extension method 'addLast' accepting a first argument of type 'System.Collections.Generic.LinkedList' could be found (are you missing a using directive or an assembly reference?) This is part of a simple program using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Hanoi { public class Sol { public LinkedList<int?> t1 = new LinkedList<int?>(); public LinkedList<int?> t2 =new LinkedList<int?>(); public LinkedList<int?> t3 =new LinkedList<int?>(); public int depth; public LinkedList<Sol> neighbors; public Sol(LinkedList<int?> t1, LinkedList<int?> t2, LinkedList<int?> t3) { this.t1 = t1; this.t2 = t2; this.t3 = t3; neighbors = new LinkedList<Sol>(); } public virtual void getneighbors() { Sol temp = this.copy(); Sol neighbor1 = this.copy(); Sol neighbor2 = this.copy(); Sol neighbor3 = this.copy(); Sol neighbor4 = this.copy(); Sol neighbor5 = this.copy(); Sol neighbor6 = this.copy(); if (temp.t1.Count != 0) { if (neighbor1.t2.Count != 0) { if (neighbor1.t1.First.Value < neighbor1.t2.First.Value) { neighbor1.t2.AddFirst(neighbor1.t1.RemoveFirst()); neighbors.AddLast(neighbor1); } } else { neighbor1.t2.AddFirst(neighbor1.t1.RemoveFirst()); neighbors.AddLast(neighbor1); } if (neighbor2.t3.Count != 0) { if (neighbor2.t1.First.Value < neighbor2.t3.First.Value) { neighbor2.t3.AddFirst(neighbor2.t1.RemoveFirst()); neighbors.AddLast(neighbor2); } } else I hope that you find someone to help me

    Read the article

  • Java threads not working correctly with linkedlist

    - by user69514
    Hi I am working on the sleeping barber problem. with the addition of having priority customer when they arrive they go in the front of the line and they are the next ones to get a haircut. I'm using a linkedlist and if I see a priority customer I put him in the beginning of the list, if the customer is not priority he goes to the end of the list. then I call the wantHaircut method getting the first element of the list. my problem is that the customer are being processed in the order they arrive, and the priority customer have to wait. here is the code where it all happens. any ideas what I am doing wrong? thanks public void arrivedBarbershop(Customer c){ if(waiting < numChairs && c.isPriority()){ System.out.println("Customer " + c.getID() + ": is a priority customer - SITTING -"); mutex.up(); customer_list.addFirst(c); } else if(waiting >= numChairs && c.isPriority()){ System.out.println("Customer " + c.getID() + ": is a priority customer - STANDING -"); mutex.up(); customer_list.addFirst(c); } else if(waiting < numChairs && !c.isPriority()){ waiting++; System.out.println("Customer " + c.getID() + ": arrived, sitting in the waiting room"); customer_list.addLast(c); customers.up(); // increment waiting customers } else if(waiting >= numChairs && !c.isPriority()) { System.out.println("Customer " + c.getID() + ": went to another barber because waiting room was full - " + waiting + " waiting"); mutex.up(); } if(!customer_list.isEmpty()){ this.wantHairCut(customer_list.removeFirst()); } } public void wantHairCut(Customer c) { mutex.up(); barber.down(); // waits for being allowed in barber chair System.out.println("Customer " + c.getID() + ": getting haircut"); try { /** haircut takes between 1 and 2 seconds **/ Thread.sleep(Barbershop.randomInt(1, 2) * 1000); } catch (InterruptedException e) { } System.out.println("Barber: finished cutting customer " + c.getID() + "'s hair"); c.gotHaircut = true; cutting.up(); // signals cutting has finished /** customer must pay now **/ this.wantToCashout(c); }

    Read the article

  • help me with xor encryption in c#

    - by x86shadow
    I wrote this code in c# to encrypt a text with a key : using System; using System.Linq; using System.Collections.Generic; using System.Text; namespace ENCRYPT { class XORENC { private static int Bin2Dec(string num) { int _num = 0; for (int i = 0; i < num.Length; i++) { _num += (int)Math.Pow(2, num.Length - i - 1) * int.Parse(num[i].ToString()); } return _num; } private static string Dec2Bin(int num) { if (num < 2) return num.ToString(); return Dec2Bin(num / 2) + (num % 2).ToString(); } public static string StrXor(string str, string key) { string _str = ""; string _key = ""; string _dec = ""; string _temp = ""; for (int i = 0; i < str.Length; i++) { _temp = Dec2Bin(str[i]); for (int j = 0; j < 8 - _temp.Length + 1; j++) { _temp = '0' + _temp; } _str += _temp; } for (int i = 0; i < key.Length; i++) { _temp = Dec2Bin(key[i]); for (int j = 0; j < 8 - _temp.Length + 1; j++) { _temp = '0' + _temp; } _key += _temp; } while (_key.Length < _str.Length) { _key += _key; } if (_key.Length > _str.Length) _key = _key.Substring(0, _str.Length); for (int i = 0; i < _str.Length; i++) { if (_str[i] == _key[i]) { _dec += '0'; } else { _dec += '1'; } } _str = ""; for (int i = 0; i < _dec.Length; i = i + 8) { char _chr = (char)0; _chr = (char)Bin2Dec(_dec.Substring(i, 8)); _str += _chr; } return _str; } } } the problem is that I always get error when I want to decrypt an encryted text with this code. see the example below for more info : string enc_text = ENCRYPT.XORENC("abc","a"); //enc_text = " ??" string dec_text = ENCRYPT.XORENC(enc_text,"a"); //ERROR any one can help ?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >