473,800 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

converting code using Java Vector to PHP

I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product.

The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertEl ementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.

I don't see any way to really emulate this behavior in with PHP
arrays.

Any thoughts?

....
Krick
Jul 17 '05 #1
2 2136
On 29 Sep 2004 13:21:37 -0700, wk****@gmail.co m (William Krick) wrote:
I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product.

The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertEl ementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.

I don't see any way to really emulate this behavior in with PHP
arrays.

Any thoughts?


http://uk.php.net/manual/en/function.array-splice.php , see final example.

--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
William Krick <wk****@gmail.c om> wrote:
I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product. The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertEl ementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.


$input = array("red", "green", "blue", "yellow");
array_splice($i nput, 3, 0, "purple");
// $input is now array("red", "green",
// "blue", "purple", "yellow");

http://www.php.net/manual/en/function.array-splice.php

hope this helps

--
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Salil Das | It's ok to kiss a fool,
bugs@cc | It's ok to let a fool kiss you,
| but never ever let a kiss fool you.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6826
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for elements, attributes, ".", and "..", plus also the "" predicate format is supported - however, only one predicate per path step is supported, and expr must be a relative path. 2. Poor performance
67
4286
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++. That usually serves to divert the discussion from the technical subject to a discussion of the...
24
1640
by: cs_hart | last post by:
I have an application in Java that I would like to port to c++ to integrate with existing c++ app. Is anyone aware of any tools to help? I found microsft has a java->c# convert, but the java app has class that do multiple subclassing and this doesn't seem to work in C#. Is there any to port C# to c++? thanks...charlie
13
4658
by: ppateel | last post by:
Hi, I am new to c++ and I am converting a c program to c++. I changed malloc call to new and I am getting an exception violation. Here is the relevant piece of code. Compiler vc++ 7.0 (.Net 2003) SQLINTEGER nCols; SQLINTEGER cbColDataLength; PBYTE* pColumnData = NULL;
3
2187
by: fakeprogress | last post by:
How would I go about converting this C code to C++? /* LIBRARY is an array of structures */ /* This function compares 'tcode' with */ /* existing codes in the array. */ /* It returns the index of the code in */ /* the LIBRARY structure if it is found. */ int findcode( LIBRARY *b, int n, char *tcode ) { int i;
12
2694
by: steven acer | last post by:
hello, i have a java app that constructs an xml from a specific file format and vice versa. i've been asked to convert it to c++, but im not an expert in c++, actually im mere beginner you can say. i got a couple of questions though: 1- is there any equivalent to java's Stream classes(ByteArrayInputStream,InputStreamRedare,DataInputStream ..) 2- how to open a stream on a byte ( char) array in c++ in order to read it as text. i have a...
2
4011
by: CoreyWhite | last post by:
Problem: You have numbers in string format, but you need to convert them to a numeric type, such as an int or float. Solution: You can do this with the standard library functions. The functions strtol, strtod, and strtoul, defined in <cstdlib>, convert a null- terminated character string to a long int, double, or unsigned long. You can use them to convert numeric strings of any base to a numeric
1
1699
by: java4life | last post by:
Java problem -------------------------------------------------------------------------------- I need to generate the following output with a TestProgram. Lecturer 65374 has 3 students: Student number 1 has name of Amanda Student number 2 has name of Patrick Student number 3 has name of Jay The Student and Lecturer classes are below.
10
7931
by: Curious | last post by:
A business associate told me that I should be able to run C++ code in C#.NET environment because C++ and C# belong to the same family. He sent me the code below and asked me to run in C#.NET environment. I got numerous compiling errors because #include stuff don't exist in C#! Could anyone tell me if the code below should run in C#.NET? ...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.