At the moment I am working on a project admin application in C# 3.5 on ASP.net. In order to reduce hits to the database, I'm caching a lot of information using static variables. For example, a list of users is kept in memory in a static class. The class reads in all the information from the database on startup, and will update the databa...
I am building a POP3 mailbox in PHP.
I have the following files:
server_access.php (fetch mails from the POP3 server)
data_access.php (which fetches/writes mails to local DB)
mime_parser.php (parses MIME content)
core.php (uses above files and stores parsed mail as an assoc array called $inbox)
Now, I have the pages mailbox.php to sh...
Like in C and many other languages there are static variables which retain their value between function calls. Is there any equivalent in Python?
...
In C#, is there a way to put a static variable in a method like VB.Net?
Static myCollection As Collection
...
EDIT: declaring them private was a typo, I fixed it:
Relating to another question, if I declared a static variable in a class, then derived a class from that, is there any way to declare the static variable as individual per each class. Ie:
class A:
{
public:
static int x;
};
class B:A
{
public:
const static int x;
};
does that defi...
When I use static variables in C++, I often end up wanting to initialize one variable passing another to its constructor. In other words, I want to create static instances that depend on each other.
Within a single .cpp or .h file this is not a problem: the instances will be created in the order they are declared. However, when you wan...
I have a function in R that I call multiple times. I want to keep track of the number of times that I've called it and use that to make decisions on what to do inside of the function. Here's what I have right now:
f = function( x ) {
count <<- count + 1
return( mean(x) )
}
count = 1
numbers = rnorm( n = 100, mean = 0, sd = 1 )
fo...
Well, I think I have a very basic doubt here:
I'm developing an app on GAE (Java) and performing a query to the datastore that returns a lot
of entities, so I need to cache it. I was using memcache and it was working great, but if I keep the list of entities in a static variable, the whole request goes as twice as fast than using memca...
I know .OBJ is the result of compiling a unit of compilation and .LIB is a static library that can be created from several .OBJ, but this difference seems to be only in the number of units of compilation. Is there any other difference? Is it the same or different file format?
I have come to this question when wondering if the same stati...
I want to have the same static variable with a different value depending on the type of class.
So I would have
public class Entity
{
public static Bitmap sprite;
public void draw(Canvas canvas, int x, int y)
{
canvas.drawBitmap(sprite, x, y, null);
}
}
public class Marine extends Entity
{
}
public clas...
Can you tell me how long a variable lives in a program (in Java). i.e. variables declared inside methods, variables used in parameters, STATIC variables, variables used to return from a method, etc.
Thanks.
...
I am writing an application and I will have some dictionary values in many different languages. I know I could use GetText, but AFAIR files have to be compiled after editing, and I want to let user edit dictionary, and I can't recompile .mo files on the server. I don't know how many languages will be used, so solution must be elastic.
I...
Without any code in the subclasses, I'd like an abstract class to have a different copy of a static variable for each subclass. In C#
abstract class ClassA
{
static string theValue;
// just to demonstrate
public string GetValue()
{
return theValue;
}
...
}
class ClassB : ClassA { }
class ClassC : ClassA ...
I've got an application that's using a static library I made. One .cpp file in the library has a static variable declaration, whose ctor calls a function on a singleton that does something- e.g. adds a string.
Now when I use that library from the application, my singleton doesn't seem to contain any traces of the string that was suppos...
I have some C# library classes that make use of static variables. I use these library classes both for desktop and web applications. Problem is, as I just discovered, static variables don't go down so well on a web server; the values are shared across all sessions using the web site!
How can I preserve the features of a static variabl...
In C language, I want to access a global static variable outside the scope of the file . Let me know the best possible way to do it.
One of the methods is to assign an extern global variable the value of static variable,
In file a.c
static int val=10;
globalvar =val;
In file b.c
extern globalvar ;
But in this case any changes in val...
I was trying to create a static variable to store a dictionary of images. Unfortunately, the best way I could find to initialise it was to check in each function that used the variable. Since I am creating this variable inside a category, I can't just initialise it inside the initialiser. Is there a neater way of initialising navigationB...
Hi,
I've got two different forms in my WinForms app (MainForm and Form2 say). They both ask for an access of MyDataSet, via a "getInstance" static method. The issue is after MainForm has got an instance, when Form2 needs to get an instance the static "myDataSet" variable is null, whereas I expect to have been already set? Any ideas?
...
I have concept of static variables but what are the benefits of static methods in a class. I have worked on some projects but I did not make a method static. Whenever I need to call a method of a class, I create an object of that class and call the desired method.
Q: Static variable in a method holds it's value even when method is exec...
Hi all,
I've written a simple library file with a function for reading lines from a file of any size. The function is called by passing in a stack-allocated buffer and size, but if the line is too big, a special heap-allocated buffer is initialized and used to pass back a larger line.
This heap-allocated buffer is function-scoped and d...