Search Results

Search found 59230 results on 2370 pages for 'character set'.

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

  • Looking for a non-cryptographic hash function that returns a single character

    - by makerofthings7
    Suppose I have a dictionary of ASCII words stored in uppercase. I also want to save those words into separate files so that the total word count of each file is approximately the same. By simply looking at the word I need to know which file it should be in (if it's there at all). Duplicate words should go into the same file and overwrite the last one. My first attempt at solving this problem is to use .NET's object.GetHashCode() function and .Trim() to get one of the "random" characters that pop up. I asked a similar question here If I only use one character of object.GetHashCode() I would get a hash code character of A..Z or 0..9. However saving the result of GetHashCode to disk is a no-no so I need a substitute. Question: What algorithm (or subset of an algorithm) is appropriate for pigeonholing strings into a single character or range of characters (Like hex 0..F offers 16 chars)? Real world usage: I'll use this answer to modify the Partition key used in Azure Table storage as described here

    Read the article

  • Data structure to build and lookup set of integer ranges

    - by actual
    I have a set of uint32 integers, there may be millions of items in the set. 50-70% of them are consecutive, but in input stream they appear in unpredictable order. I need to: Compress this set into ranges to achieve space efficient representation. Already implemented this using trivial algorithm, since ranges computed only once speed is not important here. After this transformation number of resulting ranges is typically within 5 000-10 000, many of them are single-item, of course. Test membership of some integer, information about specific range in the set is not required. This one must be very fast -- O(1). Was thinking about minimal perfect hash functions, but they do not play well with ranges. Bitsets are very space inefficient. Other structures, like binary trees, has complexity of O(log n), worst thing with them that implementation make many conditional jumps and processor can not predict them well giving poor performance. Is there any data structure or algorithm specialized in integer ranges to solve this task?

    Read the article

  • Pair equal operator overloading for inserting into set

    - by Petwoip
    I am trying to add a pair<int,int> to a set. If a pair shares the same two values as another in the set, it should not be inserted. Here's my non-working code: typedef std::pair<int, int> PairInt; template<> bool std::operator==(const PairInt& l, const PairInt& r) { return (l.first == r.first && l.second == r.second) || (l.first == r.second && l.second == r.first); } int main() { std::set<PairInt> intSet; intSet.insert(PairInt(1,3)); intSet.insert(PairInt(1,4)); intSet.insert(PairInt(1,4)); intSet.insert(PairInt(4,1)); } At the moment, the (4,1) pair gets added even though there is already a (1,4) pair. The final contents of the set are: (1 3) (1 4) (4 1) and I want it to be (1 3) (1 4) I've tried putting breakpoints in the overloaded method, but they never get reached. What have I done wrong?

    Read the article

  • How to create custom get and set methods for Linq2SQL object

    - by optician
    I have some objects which have been created automatically by linq2SQL. I would like to write some code which should be run whenever the properties on these objects are read or changed. Can I use typical get { //code } and set {//code } in my partial class file to add this functionality? Currently I get an error about this member already being defined. This all makes sense. Is it correct that I will have to create a method to function as the entry point for this functionality, as I cannot redefine the get and set methods for this property. I was hoping to just update the get and set, as this would mean I wouldn't have to change all the reference points in my app. But I think I may just have to update it everywhere.

    Read the article

  • Java: Set<E> collection, where items are identified by its class

    - by mschayna
    I need Set collection, where its items will be identified by items class. Something like ReferenceIdentityMap from Appache Collections, but on class scope i.e. two different instances of same class must be identified as same in this collection. You know, it is a violation of equals()/hashCode() identity principle but in occasional use it makes sense. I have done this in simple class backing with Map<Class<? extends E>, E>, but due to simplicity it doesn't implement Set<E>. There may be a more elegant solution, decorator of any Set<E> would be great. Is there any implementation of such collection there (Apache/Google/something/... Collections)?

    Read the article

  • C++: need indexed set

    - by user231536
    I need an indexed associative container that operates as follows: initially empty, size=0. when I add a new element to it, it places it at index [size], very similar to a vector's push_back. It increments the size and returns the index of the newly added element. if the element already exists, it returns the index where it occurs. Set seems the ideal data structure for this but I don't see any thing like getting an index from a find operation. Find on a set returns an iterator to the element. Will taking the difference with set.begin() be the correct thing to do in this situation?

    Read the article

  • flex: cant edit item in Datagrid with override set data method

    - by Markus
    Hi everybody, I've a custom itemRenderer for my datagrid. To set the actual data I use the following method: override public function set data(side:Object):void{ ... } As soon as I use this function the cell doesn't show up any item Editor anymore. Why is that? When I remove this function the itemEditor is working but with the wrong initialization data... What's the proper way to handle this? Thanks, Markus

    Read the article

  • dynamically set the control template

    - by Saboor
    hi, i am using dictionaries in WPF. i have two bitmap image in it with name something like image1 and image2 now in forms, i like to set them to single image control depending on condition, some times image1 and sometimes image2. so how i set the source dynamically, in dictonary i have UriSource="/wpf1;component/images/infobarGreen.png" / UriSource="/wpf1;component/images/infobarRed.png" /

    Read the article

  • Java - Is Set.contains() broken on OpenJDK 6?

    - by Peter
    Hey, I've come across a really strange problem. I have written a simple Deck class which represents a standard 52 card deck of playing cards. The class has a method missingCards() which returns the set of all cards which have been drawn from the deck. If I try and compare two identical sets of missing cards using .equals() I'm told they are different, and if I check to see if a set contains an element that I know is there using .contains() I am returned false. Here is my test code: public void testMissingCards() { Deck deck = new Deck(true); Set<Card> drawnCards = new HashSet<Card>(); drawnCards.add(deck.draw()); drawnCards.add(deck.draw()); drawnCards.add(deck.draw()); Set<Card> missingCards = deck.missingCards(); System.out.println(drawnCards); System.out.println(missingCards); Card c1 = null; for (Card c : drawnCards){ c1 = c; } System.out.println("C1 is "+c1); for (Card c : missingCards){ System.out.println("C is "+c); System.out.println("Does c1.equal(c) "+c1.equals(c)); System.out.println("Does c.equal(c1) "+c.equals(c1)); } System.out.println("Is c1 in missingCards "+missingCards.contains(c1)); assertEquals("Deck confirm missing cards",drawnCards,missingCards); } (Edit: Just for clarity I added the two loops after I noticed the test failing. The first loop pulls out a card from drawnCards and then this card is checked against every card in missingCards - it always matches one, so that card must be contained in missingCards. However, missingCards.contains() fails) And here is an example of it's output: [5C, 2C, 2H] [2C, 5C, 2H] C1 is 2H C is 2C Does c1.equal(c) false Does c.equal(c1) false C is 5C Does c1.equal(c) false Does c.equal(c1) false C is 2H Does c1.equal(c) true Does c.equal(c1) true Is c1 in missingCards false I am completely sure that the implementation of .equals on my card class is correct and, as you can see from the output it does work! What is going on here? Cheers, Pete

    Read the article

  • How to set background color of a View

    - by Peter vdL
    I'm trying to set the background color of a View (in this case a Button). I use this code: // set the background to green v.setBackgroundColor(0x0000FF00 ); v.invalidate(); It causes the Button to disappear from the screen. What am I doing wrong, and what is the correct way to change the background color on any View? Thanks.

    Read the article

  • Twitter like character counter - jQuery version

    - by bipinjoshi
    My recent article titled "Displaying a Character Counter for Multiline Textboxes" shows you how to create a character counter like Twitter for multiline textboxes. The articles does so using ASP.NET AJAX client behavior. Here is a jQuery version of the code that does similar job. Note, however, that unlike ASP.NET AJAX client behavior as illustrated in the article the following code takes a "function" based approach to quickly implement similar functionality.http://www.bipinjoshi.net/articles/84e691b2-0306-4911-87bb-875806ba981b.aspx

    Read the article

  • What is a good resource for HTML character codes -> glyph and...

    - by Ben
    Hi, I've already found a good site to convert HTML character codes to their respective glyphs: http://www.public.asu.edu/~rjansen/glyph_encoding.html However, I need a bit more information. Does anyone know of a site like the one above that also provides information on what type of character code it is? Meaning, is it a special character? Is the glyph visible? Etc... So far I have found some tables with this information, but they aren't as complete as the resource above. I would really like to get my hands on a complete table. Thanks, -Ben

    Read the article

  • Capturing Set Behavior with Mutating Elements

    - by Carl
    Using the Guava library, I have the following situation: SetMultimap<ImmutableFoo, Set<Foo>> setMM = HashMultimap.create(); Set<Foo> mask = Sets.newHashSet(); // ... some iteration construct { setMM.put(ImmutableFoo1, Sets.difference(SomeSetFoo1,mask)); setMM.put(ImmutableFoo1, Sets.difference(SomeSetFoo2,mask)); mask.add(someFoo); } that is, the same iteration to create the setMM is also used to create the mask - this can of course result in changes to hashCode()s and create duplicates within the SetMultimap backing. Ideally, I'd like the duplicates to drop without me having to make it happen, and avoid repeating the iteration to separately construct the multimap and mask. Any easy libraries/Set implementations to make that happen? Alternatively, can you identify a better way to drop the duplicates than: for (ImmutableFoo f : setMM.keySet()) setMM.putAll(f,setMM.removeAll(f)); revisiting the elements is probably not a performance problem, since I could combine a separate filter operation that needs to visit all the elements anyway.

    Read the article

  • How many bytes does Oracle use when storing a single character?

    - by Mr-sk
    I tried to look here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i3253 And I understand that I have to provide string length for the column, I'm just not able to find out how many bytes oracle uses when storing a character. My limit is 500 characters, so if its 1 byte / character, I can create the column with 500, if its 2 byte / character then 1000, etc. Anyone have a link to the documentation or know for certain? In case it matters, the SQL is being called from PHP, so these are PHP strings I'm inserting into the database. Thanks.

    Read the article

  • CMD For Loop does not hold set /a value

    - by Bob Hope
    Didn't know how to explain this well, so here is the code @echo off set test=0 for /f %%a in (textfile.txt) do ( rem loops five times(5 lines in textfile.txt) set /a test=test+1 rem Adds 1 to Test echo %%a rem Echo's correct line in file echo %test% rem Echo's whatever X was before the loop ) echo %test% rem Displays the correct value of X pause this is just an example of where I am finding the problem, txtfile.txt has 5 lines, so the for loop goes 5 times, each time, test gets +1 to it, and the /a displays the correct value of X, but the last echo on the for loop displays 0, which is what test is set to before the loop. The value of test is not changing until the loop is finished... is there any way to fix this? Here is what I want to accomplish, as there may be an easier way: I want to run a for loop that findstr's all rtf's in a series of sub folders, and copies them all to a all directory with a new name, 1.rtf,2.rtf,3.rtf, etc. The reason I need to rename them on the transfer is they all have the same name.

    Read the article

  • How to use java.Set

    - by owca
    I'm trying to make it working for quite some time,but just can't seem to get it. I have object Tower built of Block's. I've already made it working using arrays, but I wanted to learn Set's. I'd like to get similar functionality to this: public class Tower { public Tower(){ } public Tower add(Block k1){ //(...) //if block already in tower, return "Block already in tower" } public Tower delete(Block k1){ //(...) //if block already dleted, show "No such block in tower" } } Someone gave me some code, but I constantly get errors when trying to use it : Set<Block> tower = new HashSet<Block>(); boolean added = tower.add( k1 ); if( added ) { System.out.println("Added 1 block."); } else { System.out.println("Tower already contains this block."); } How to implement it ?

    Read the article

  • Adjacency List Tree Using Recursive WITH (Postgres 8.4) instead of Nested Set

    - by Koobz
    I'm looking for a Django tree library and doing my best to avoid Nested Sets (they're a nightmare to maintain). The cons of the adjacency list model have always been an inability to fetch descendants without resorting to multiple queries. The WITH clause in Postgres seems like a solid solution to this problem. Has anyone seen any performance reports regarding WITH vs. Nested Set? I assume the Nested set will still be faster but as long as they're in the same complexity class, I could swallow a 2x performance discrepancy. Django-Treebeard interests me. Does anyone know if they've implemented the WITH clause when running under Postgres? Has anyone here made the switch away from Nested Sets in light of the WITH clause?

    Read the article

  • How to SET ARITHABORT ON for connections in Linq To SQL

    - by Laurence
    By default, the SQL connection option ARITHABORT is OFF for OLEDB connections, which I assume Linq To SQL is using. However I need it to be ON. The reason is that my DB contains some indexed views, and any insert/update/delete operations against tables that are part of an indexed view fail if the connection does not have ARITHABORT ON. Even selects against the indexed view itself fail if the WITH(NOEXPAND) hint is used (which you have to use in SQL Standard Edition to get the performance benefit of the indexed view). Is there somewhere in the data context I can specify I want this option ON? Or somewhere in code I can do it?? I have managed a clumsy workaround, but I don't like it .... I have to create a stored procedure for every select/insert/update/delete operation, and in this proc first run SET ARITHABORT ON, then exec another proc which contains the actual select/insert/update/delete. In other words the first proc is just a wrapper for the second. It doesn't work to just put SET ARITHABORT ON above the select/insert/update/delete code.

    Read the article

  • Java creation of new set too slow

    - by Mgccl
    I have this program where it have some recursive function similar to this: lambda(HashSet<Integer> s){ for(int i=0;i<w;i++){ HashSet<Integer> p = (HashSet) s.clone(); p.addAll(get_next_set()); lambda(p); } } What I'm doing is union every set with the set s. And run lambda on each one of the union. I run a profiler and found the c.clone() operation took 100% of the time of my code. Are there any way to speed this up considerably?

    Read the article

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