Search Results

Search found 2571 results on 103 pages for 'extend'.

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

  • C# Extend array type to overload operators

    - by Episodex
    I'd like to create my own class extending array of ints. Is that possible? What I need is array of ints that can be added by "+" operator to another array (each element added to each), and compared by "==", so it could (hopefully) be used as a key in dictionary. The thing is I don't want to implement whole IList interface to my new class, but only add those two operators to existing array class. I'm trying to do something like this: class MyArray : Array<int> But it's not working that way obviously ;). Sorry if I'm unclear but I'm searching solution for hours now... UPDATE: I tried something like this: class Zmienne : IEquatable<Zmienne> { public int[] x; public Zmienne(int ilosc) { x = new int[ilosc]; } public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return false; } return base.Equals((Zmienne)obj); } public bool Equals(Zmienne drugie) { if (x.Length != drugie.x.Length) return false; else { for (int i = 0; i < x.Length; i++) { if (x[i] != drugie.x[i]) return false; } } return true; } public override int GetHashCode() { int hash = x[0].GetHashCode(); for (int i = 1; i < x.Length; i++) hash = hash ^ x[i].GetHashCode(); return hash; } } Then use it like this: Zmienne tab1 = new Zmienne(2); Zmienne tab2 = new Zmienne(2); tab1.x[0] = 1; tab1.x[1] = 1; tab2.x[0] = 1; tab2.x[1] = 1; if (tab1 == tab2) Console.WriteLine("Works!"); And no effect. I'm not good with interfaces and overriding methods unfortunately :(. As for reason I'm trying to do it. I have some equations like: x1 + x2 = 0.45 x1 + x4 = 0.2 x2 + x4 = 0.11 There are a lot more of them, and I need to for example add first equation to second and search all others to find out if there is any that matches the combination of x'es resulting in that adding. Maybe I'm going in totally wrong direction?

    Read the article

  • JUnit confusion: use 'extend Testcase' or '@Test' ?

    - by Rabarberski
    I've found the proper use (or at least the documentation) of JUnit very confusing. This question serves both as a future reference and as a real question. If I've understood correctly, there are two main approaches to create and run a JUnit test: Approach A: create a class that extends TestCase, and start test methods with the word test. When running the class as a JUnit Test (in Eclipse), all methods starting with the word test are automatically run. import junit.framework.TestCase; public class DummyTestA extends TestCase { public void testSum() { int a = 5; int b = 10; int result = a + b; assertEquals(15, result); } } Approach B: create a 'normal' class and prepend a @Test annotation to the method. Note that you do NOT have to start the method with the word test. import org.junit.*; import static org.junit.Assert.*; public class DummyTestB { @Test public void Sum() { int a = 5; int b = 10; int result = a + b; assertEquals(15, result); } } Mixing the two seems not to be a good idea, see e.g. this stackoverflow question: Now, my questions(s): What is the preferred approach, or when would you use one instead of the other? Approach B allows for testing for exceptions by extending the @Test annotation like in @Test(expected = ArithmeticException.class). But how do you test for exceptions when using approach A? When using approach A, you can group a number of test classes in a test suite. TestSuite suite = new TestSuite("All tests");<br/> suite.addTestSuite(DummyTestA.class); suite.addTestSuite(DummyTestAbis.class);` But this can't be used with approach B (since each testclass should subclass TestCase). What is the proper way to group tests for approach B?

    Read the article

  • ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDO'

    - by Nitin Gurram
    I am trying to update the table which has millions of records. However my update query will update around 2-3 millions of records. I am facing below error on executing the update query. I googled and found that I need to update the Table Space as DBA But is there any work around for executing the update without actually extending the UNDO table space or something dba is not required UPDATESERVICE SET CREATION_TIME = LAST_UPDATE_TIME WHERE CREATION_TIME is null

    Read the article

  • Why do case class companion objects extend FunctionN?

    - by retronym
    When you create a case class, the compiler creates a corresponding companion object with a few of the case class goodies: an apply factory method matching the primary constructor, equals, hashCode, and copy. Somewhat oddly, this generated object extends FunctionN. scala> case class A(a: Int) defined class A scala> A: (Int => A) res0: (Int) => A = <function1> This is only the case if: There is no manually defined companion object There is exactly one parameter list There are no type arguments The case class isn't abstract. Seems like this was added about two years ago. The latest incarnation is here. Does anyone use this, or know why it was added? It increases the size of the generated bytecode a little with static forwarder methods, and shows up in the #toString() method of the companion objects: scala> case class A() defined class A scala> A.toString res12: java.lang.String = <function0>

    Read the article

  • How can I extend PHP DOMElement?

    - by Michael Tsang
    a.php #!/usr/bin/php <?php class HtmlTable extends DOMElement { public function __construct($height, $width) { parent::__construct("table"); for ($i = 0; $i < $height; ++$i) { $row = $this->appendChild(new DOMElement("tr")); for($j = 0; $j < $width; ++$j) { $row->appendChild(new DOMElement("td")); } } } } $document = new DOMDocument("1.0", "UTF-8"); $document->registerNodeClass("DOMElement", "HtmlTable"); $document->appendChild(new HtmlTable(3, 2)); $document->saveXML(); Running it gets Fatal error: Uncaught exception 'DOMException' with message 'No Modification Allowed Error' in /home/www/a.php:9 Stack trace: #0 /home/www/a.php(9): DOMNode->appendChild(Object(DOMElement)) #1 /home/www/a.php(19): HtmlTable->__construct(3, 2) #2 {main} thrown in /home/www/a.php on line 9

    Read the article

  • Is it legal to extend the Class class?

    - by spiralganglion
    I've been writing a system that generates some templates, and then generates some objects based on those templates. I had the idea that the templates could be extensions of the Class class, but that resulted in some magnificent errors: VerifyError: Error #1107: The ABC data is corrupt, attempt to read out of bounds. What I'm wondering is if subclassing Class is even possible, if there is perhaps some case where doing this would be appropriate, and not just a gross misuse of OOP. I believe it should be possible, as ActionScript allows you to create variables of the Class type. This use is described in the LiveDocs entry for Class, yet I've seen no mentions of subclassing Class. Here's a pseudocode example: class Foo extends Class var a:Foo = new Foo(); trace(a is Class) // true, right? var b = new a(); I have no idea what the type of b would be. In summary: can you subclass the Class class? If so, how can you do it without errors, and what type are the instances of the instances of the Class subclass?

    Read the article

  • Extend a direct instance

    - by Diolor
    We have a new instance of an object with four properties: person={firstname:"John",lastname:"Doe",age:50,eyecolor:"blue"}; What is the best way to many other properties to that object? If we wanted few couple more sure we would: person[address_no] = 4; .... person[country] = 'Netherlands'; But what if we have a lot properties. Is there any minimalistic way like the one below? (I know it doesn't work) person +={address_no: '4', .... , country: 'Netherlands'};

    Read the article

  • How can you configure or extend BITS (Background Intelligent Transfer Service) to read files from a

    - by Mark
    I have a ASP .NET load balanced application (webservice and website). It runs on SQL server. I need to be able to provide large files for download. However, because of the load balancing situation, the files are stored in the SQL database as opposed to the file system. BITS seems to be the best approach. I have full control of the client. However, i don't know how to configure BITS to read the file from the database. I know how to write the C# code for that, but i don't know how to get BITS to hook into it as opposed to reading the file from the file system. Any ideas?

    Read the article

  • Extend precision of MySQL's double datatype?

    - by tim82
    I am trying to save the value "6.714285714285714" into a DOUBLE datatype field. Unfortunately it does not fit at all and is cutted by one char. Storing larger numbers becomes less precise. Already searched in the mysql manual and it seems to be that double is the most precise data type available. Anyone knows a practicable workaround? Sorry for my bad english and thx a lot!

    Read the article

  • Extend DOMElement object

    - by Comma
    How could I exdend objects provided with Document Object Model? Seems that there is no way according to this [issue][2]. class Application_Model_XmlSchema extends DOMElement { const ELEMENT_NAME = 'schema'; /** * @var DOMElement */ private $_schema; /** * @param DOMDocument $document * @return void */ public function __construct(DOMDocument $document) { $this->setSchema($document->getElementsByTagName(self::ELEMENT_NAME)->item(0)); } /** * @param DOMElement $schema * @return void */ public function setSchema(DOMElement $schema){ $this->_schema = $schema; } /** * @return DOMElement */ public function getSchema(){ return $this->_schema; } /** * @param string $name * @param array $arguments * @return mixed */ public function __call($name, $arguments) { if (method_exists($this->_schema, $name)) { return call_user_func_array( array($this->_schema, $name), $arguments ); } } } $version = $this->getRequest()->getParam('version', null); $encoding = $this->getRequest()->getParam('encoding', null); $source = 'http://www.w3.org/2001/XMLSchema.xsd'; $document = new DOMDocument($version, $encoding); $document->load($source); $xmlSchema = new Application_Model_XmlSchema($document); $xmlSchema->getAttribute('version'); I got an error: Warning: DOMElement::getAttribute(): Couldn't fetch Application_Model_XmlSchema in C:\Nevermind.php on line newvermind

    Read the article

  • Can a class Extend or Override himself?

    - by EBAGHAKI
    Suppose we have a class. We create an object from the class and when we do the class Extends himself base on the object initialization value.. For example: $objectType1 = new Types(1); $objectType1->Activate(); // It calls an activation function for type 1 $objectType2 = new Types(2); $objectType2->Activate(); // It calls an activation function for type 2 I don't want to use the standard procedure of class extending: class type1 extends types{}

    Read the article

  • WPF - Extend ListView with checkable AND selectable ListViewItems

    - by Marks
    Hi there. I already read many examples on extending ListViews with checkboxes bound with IsSelected. But I want something more. I want a seperation between the checked and selected state, so i get a ListBox that has a single selected item, but can have multiple checked items. Unfortunately ListViewItem does not have a property for checked and I dont see a possibility to get the ListView to work with a custom CheckableListViewItem. Of course i could use a List of objects with a checked property as ItemSource, but I dont think thats a good way to go. Checked or not is a matter of the list or item-container, not of the object listed in it. Beside that I dont want all my classes like user, role, group to have counterparts like checkableUser, checkableRole and checkableGroup. The behaviour i want can be easyly accomblished for the UI with a <DataTemplate x:Key="CheckBoxCell"> <StackPanel Orientation="Horizontal"> <CheckBox /> </StackPanel> </DataTemplate> and a <GridViewColumn CellTemplate="{StaticResource CheckBoxCell}" Width="30"/> But without a binding on the checkbox i cant check if it is checked or not. Is there any way to accomplish something like that? The perfect solution for me would be to have listView1.SelectedItem, listView1.CheckedItems and maybe a listView1.UncheckedItems and of course listView1.CheckItem and listView1.UncheckItem. Thanks for any help.

    Read the article

  • How to extend per environment configuration in grails

    - by skurt
    It seems that only grails.serverURL and grails.path are recognized as per environment configrautions. bla and foo are ignored and could not be used in application Anyone could solves this and provide a way to get bla and foo configured per environment? environments { production { grails.serverURL = "http://alpha.foo.de" grails.path = "" bla = "text" foo= "word" } test { grails.serverURL = "http://test.foo.de" grails.path = "" bla = "othertext" foo= "otherword" } }

    Read the article

  • Extend a function to support more items

    - by danit
    Im trying to use this function with Wordpress: http://www.wprecipes.com/post-on-your-wordpress-blog-using-php When trying to add extra options im hitting problems: Using the Wordpress Codex here: http://codex.wordpress.org/Function_Reference/wp_insert_post Specifically trying to add: 'post_date' => [ Y-m-d H:i:s ] //The time post was made. 'post_excerpt' => [ <an excerpt> ] //For all your post excerpt needs. Can anyone add them to the function for me?

    Read the article

  • How do I extend the classpath used for 'grails run-app'

    - by Eric
    I have the following in my Config.groovy file: grails.config.locations = [ "classpath:env.groovy" ] Now, where exactly am I supposed to place "env.groovy" such that it is available on the CLASSPATH during grails run-app? The documentation here is sorely lacking. I am able to get it to work on the pure commandline by placing "env.groovy" in $APP_HOME/etc and then running: $ grails -classpath ./etc run-app This seems a little hackish, but I can live with it... However, I am unable to get any such configuration working when I launch run-app using the Grails eclipse plugin (STS): Unable to load specified config location classpath:env.groovy : class path resource [env.groovy] cannot be opened because it does not exist I've seen related posts here, here, here, and here but the answers have been unfulfilling. I am looking for a CLASSPATH-based solution that will work with 'run-app' in development mode (both commandline and from eclipse). I know how to set up the CLASSPATH for my deployment servlet container, so that is not an issue.

    Read the article

  • wanted to extend jQuery to handle a custom enter key event based on tabindex

    - by ullasvk
    I write the following code to handle when the enter key pressed an with few validation like if it is a textarea allow only four lines and if the value is empty, focus on itself. var temp = 1; function getLines(id) { return temp=temp+id; } $("#theform").keypress(function(e){ var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; if (key == 13) { var $targ = $(e.target); var tindex = $targ.attr("tabindex"); var count =1; var focusNext = false; var allowedNumberOfLines = 4; if ($targ.is("textarea") && !$targ.is(":button,:submit")) { var lines= getLines(count); if (lines > allowedNumberOfLines) { $("#login_error").css('background', '#F7F77C').fadeIn(1000).html("Only "+allowedNumberOfLines+" Lines Allowed").fadeOut(1000); tindex++; $("[tabindex=" + tindex + "]").focus(); return false; } } else if($targ.val() =='' || $targ.val() == "undefined") { $("[tabindex=" + tindex + "]").focus(); return false; } else if($targ.val() !='' || $targ.val() != "undefined") { tindex++; $("[tabindex=" + tindex + "]").focus(); return false; } } }); Is there any way to make it a custom function so that i can just call the function like $('theform').returnPress();

    Read the article

  • margin-bottom property of a div's last element doesn't "extend" the div

    - by kitsched
    I have an element in a div, which has a background image. Below the div I have another div with another background image. Now the problem is that if the last element contained in the first div has margin-bottom applied there will be a gap between the 2 divs like this: Notice the gray gap caused by the margin-bottom property of the h2 element contained within the first div. I know this can be solved if I switch margin-bottom to padding-bottom but what if I need margin-bottom? How to fix this?

    Read the article

  • Extend MySQL implementation of PiP Algorithm?

    - by Mike
    I need to make a point in polygon MySQL query. I already found these two great solutions: http://forums.mysql.com/read.php?23,286574,286574 MySQL implementation of ray-casting Algorithm? But these functions can only check if one point is inside a poly. I have a query where the PiP part should only be one part of the query and check for x points inside a polygon. Something like this: $points = list/array/whatever of points in language of favour SELECT d.name FROM data AS d WHERE d.name LIKE %red% // just bla bla // how to do this ? AND $points INSIDE d.polygon AND myWithin( $points, d.polygo ) // or UPDATE I tried it with MBR functions like this: SET @g1 = GeomFromText('Polygon((13.43971 52.55757,13.41293 52.49825,13.53378 52.49574, 13.43971 52.55757))'); SET @g2 = GeomFromText('Point(13.497834 52.540489)'); SELECT MBRContains(@g1,@g2); G2 should NOT be inside G1 but MBR says it is.

    Read the article

  • How to extend WCF returned class properly?

    - by vikasde
    I am using a WCF service in my project. This service returns a class called "Store". I created a new local class which inherits from "Store". My class is called "ExtendedStore". My ExtendedStore looks like this: class ExtendedStore : StoreManagerService.Store { public int Id; .... } Now I am using the WCF service to cast to my class using the following code: StoreManagerService.StoreClient client = new StoreManagerService.StoreClient(); ExtendedStore store = (ExtendedStore) client.GetStore(); // bombs here I am not able to cast the returned Store class from the service to my ExtendedStore class. I get the below error message: Unable to cast object of type 'ConsoleApplication1.StoreManagerService.Store' to type 'ConsoleApplication1.ExtendedStore'. Shouldn't I be able to cast it? If not, is there a workaround?

    Read the article

  • Extend Google AppEngine User in JRuby?

    - by Ryan Montgomery
    I'm working with JRuby and DataMapper running on Google AppEngine. I want to add a property to the AppEngine::User like :active_calendar which is a reference to a Calendar kind. I was able to do something in Python this way using a back reference. Are these possible in JRuby? Is this possible? Do I need to subclass the User? Can I even do that? If so - how? Thanks!

    Read the article

  • Extend multiple classes at once

    - by Starkers
    I want to share a method amongst all Ruby's data object classes. That is to say the following classes: Hash String Number Array Firstly, any classes I've missed out? Secondly, how can I share my_method amongst all classes at once? class Hash def my_method "hi" end end class String def my_method "hi" end end class Number def my_method "hi" end end class Array def my_method "hi" end end

    Read the article

  • Cakephp: Extend search capability to hasMany Relationship

    - by Chris
    I have two models: Car hasMany Passengers Passenger belongsTo Car I want to implement a search using Cake Search. The user should input a number and the searchengine should return all cars that have less than this number passengers. In my search form: echo $form->input('passengers', array('label' => 'Passengers', 'div' => false)); In my Car model: public $filterArgs = array( array('name' => 'passengers', 'type' => 'int'), ); In the controller: public $presetVars = array( array('field' => 'passengers', 'type' => 'int') } I thought of adding a function to the model that returns the number of passengers: function countPassengers(){ return(count($this->Car->Passenger)); //Not sure if this works } And how to I implement this search criteria?: return all Cars where countPassengers()<passenger

    Read the article

  • How to extend the list of available Java Locales

    - by alfonx
    I am looking for a way to add more Locales to the Locales available in Java 1.6. But the Locales I want to create do not have ISO-3166 country codes, nor ISO-639 language codes. Is there any way to do this anyways? The Locales I want to add only differ in the language names, but the smaller an ethnic group is, the more picky they get about their identity ;-) So I thought about extending an existing Locale, something like UserDefinedLocale extends Locale { UserDefinedLocale (Locale parentLocale) {...} } but java.util.Locale is final, which makes it especially hard to hack something around... So, is the idea that the list of Java Locales is exhaustive? Am I the first to miss some more Locales?

    Read the article

  • Kernel Error during upgrade or update commands

    - by Ashesh
    I am getting these errors during sudo apt-get update and upgrade... I tried all possible options no success. I recently upgraded to 13.04 and had problems with Broadcom WiFi. Fixed tat issues using the clean script... but looks like it did not install the Kernel properly.. Here is the o/p of the few scripts I ran: ashesh@ashesh-HPdv4:~$ sudo dpkg -r bcmwl-kernel-source (Reading database ... 175338 files and directories currently installed.) Removing bcmwl-kernel-source ... Removing all DKMS Modules Done. update-initramfs: deferring update (trigger activated) Processing triggers for initramfs-tools ... update-initramfs: Generating /boot/initrd.img-3.8.0-25-generic cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/mtd/mtd.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/mtd/mtd.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/sfc/sfc.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/sfc/sfc.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_core.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_core.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/broadcom/bnx2x/bnx2x.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/broadcom/bnx2x/bnx2x.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/broadcom/cnic.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/broadcom/cnic.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/qlogic/netxen/netxen_nic.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/qlogic/netxen/netxen_nic.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/brocade/bna/bna.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/net/ethernet/brocade/bna/bna.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/scsi/libfc/libfc.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/scsi/libfc/libfc.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/scsi/advansys.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/scsi/advansys.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/scsi/be2iscsi/be2iscsi.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/scsi/be2iscsi/be2iscsi.ko’: Input/output error cp: reading ‘/lib/modules/3.8.0-25-generic/kernel/drivers/scsi/bnx2i/bnx2i.ko’: Input/output error cp: failed to extend ‘/tmp/mkinitramfs_8gjKwQ//lib/modules/3.8.0-25-generic/kernel/drivers/scsi/bnx2i/bnx2i.ko’: Input/output error Bus error (core dumped) depmod: ../libkmod/libkmod-elf.c:207: elf_get_mem: Assertion `offset < elf->size' failed. Aborted (core dumped) I am not a techie but I need your support to resolve this without re-installation from scratch....

    Read the article

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